在 cygwin 中的单独环境中运行进程
所以我有一个脚本,它创建自己的环境变量,然后由 C++ 程序访问。
我想运行这个程序的多个实例,同时我想让它们在不同的环境中运行,以避免单独的进程访问彼此的环境变量并混淆。
目前我正在做的是 打开一个新的 cygwin 窗口并: 。 ./script.sh
但我每次都必须打开一个新窗口。
SO I have a script that creates its own environment variables which are then accessed by a c++ program.
I want to run multiple instances of this program, and while doing that I want to keep them running on different environments to avoid the separate processes accessing each others environment variables and getting mixed up.
At the moment what Im doing is
open a new cygwin window and:
. ./script.sh
But I have to open a new window each time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在一个窗口中运行任意数量的
./script.sh >outN 2>errN &
(注意:每次调用使用不同的数字 N;请勿 source它们带有点)。这样它们就不能覆盖彼此的环境变量,因为每个脚本都在单独的 shell 中执行。Just run as many
./script.sh >outN 2>errN &
in one window as you like (note: use different numbers N per invocation; do not source them with the dot). This way they cannot overwrite each others environment variables because each script is executed in a separate shell.