Bdfy Bdfy - 7 months ago 19
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

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.

Comments