在python中使用: os.kill()
将使用指定信号通过pid终止进程,如何使用相同的ppid杀死所有进程?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.