I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution.
相关问题
- How to get the return code of a shell script in lu
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Stop child process when parent process stops
- Invoking Mirth Connect CLI with Powershell script
rkill command from pslist package sends given signal (or
SIGTERM
by default) to specified process and all its descendants:To kill a process tree recursively, use killtree():
Modified version of zhigang's answer:
I know that is old, but that is the better solution that i found:
brad's answer is what I'd recommend too, except that you can do away with
awk
altogether if you use the--ppid
option tops
.It's super easy to do this with python using psutil. Just install psutil with pip and then you have a full suite of process manipulation tools: