Reputation: 525
In python using: os.kill()
will kill a process by pid using a specified signal,
How would one go about killing all processes with the same ppid?
Upvotes: 2
Views: 1843
Reputation: 2025
Let's say your parent process ID is 7773.
I haven't done this myself, but you might try:
import subprocess
ppid = '7773'
subprocess.call(['pkill', '-STOP', '-P', ppid])
To get the ppid of the current process:
import os
ppid = os.getppid()
Perhaps there is a solution that is strictly python. If so, I don't know what it is.
EDIT: psutil
If you want a true python solution, the psutil package might have what you're looking for.
Upvotes: 3