Created
September 8, 2015 15:35
-
-
Save niedbalski/a35ca54c4f724206294f to your computer and use it in GitHub Desktop.
kill_proc_tree.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psutil, os | |
def kill_proc_tree(pid, including_parent=True): | |
parent = psutil.Process(pid) | |
for child in parent.get_children(recursive=True): | |
child.kill() | |
if including_parent: | |
parent.kill() | |
me = os.getpid() | |
kill_proc_tree(me) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment