Bdfy Bdfy - 1 year ago 77
Python Question

how to kill process and child processes from python?

for example from bash:

kill -9 -PID

os.kill(pid, signal.SIGKILL)
kill only parent process.

Answer Source

When you pass a negative PID to kill, it actually sends the signal to the process group by that (absolute) number. You do the equivalent with os.killpg() in Python.