for example from bash:
kill -9 -PID
os.kill(pid, signal.SIGKILL) kill only parent process.
os.kill(pid, signal.SIGKILL)
If the parent process is not a "process group" but you want to kill it with the children, you can use psutil (https://psutil.readthedocs.io/en/latest/#processes). os.killpg cannot identify pid of a non-process-group.
import psutil parent_pid = 30437 # my example parent = psutil.Process(parent_pid) for child in parent.children(recursive=True): # or parent.children() for recursive=False child.kill() parent.kill()
1.4m articles
1.4m replys
5 comments
57.0k users