Skip to content

Instantly share code, notes, and snippets.

@niedbalski
Created September 8, 2015 15:35
Show Gist options
  • Save niedbalski/a35ca54c4f724206294f to your computer and use it in GitHub Desktop.
Save niedbalski/a35ca54c4f724206294f to your computer and use it in GitHub Desktop.
kill_proc_tree.py
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