小编use*_*833的帖子

Is there a way to make os.killpg not kill the script that calls it?

I have a subprocess which I open, which calls other processes.

I use os.killpg(os.getpgid(subOut.pid), signal.SIGTERM) to kill the entire group, but this kills the python script as well. Even when I call a python script with os.killpg from a second python script, this kills the second script as well. Is there a way to make os.killpg not stop the script?

Another solution would be to individually kill every child 1process. However, even using

p = psutil.Process(subOut.pid)
child_pid = p.children(recursive=True)
for …
Run Code Online (Sandbox Code Playgroud)

python subprocess

1
推荐指数
2
解决办法
3965
查看次数

标签 统计

python ×1

subprocess ×1