【发布时间】:2013-01-25 16:11:51
【问题描述】:
我想要:
- 从我的进程 (myexe.exe arg0) 启动一个新进程 (myexe.exe arg1)
- 检索这个新进程的 PID(操作系统窗口)
- 当我使用 TaskManager Windows 命令“结束进程树”杀死我的第一个实体 (myexe.exe arg0) 时,我需要新实体 (myexe.exe arg1) 不会被杀死...
我玩过 subprocess.Popen、os.exec、os.spawn、os.system... 没有成功。
另一种解释问题的方式:如果有人杀死了myexe.exe (arg0) 的“进程树”,如何保护myexe.exe (arg1)?
编辑:同样的问题(没有答案)HERE
编辑:以下命令不保证子进程的独立性
subprocess.Popen(["myexe.exe",arg[1]],creationflags = DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP,close_fds = True)
【问题讨论】:
-
你有任何到目前为止所做的示例代码吗?