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()
2.1m questions
2.1m answers
60 comments
57.0k users