MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / kill_proc_tree

Function kill_proc_tree

DemoPrograms/Demo_psutil_Kill_Processes.py:21–38  ·  view source on GitHub ↗

Kill a process tree (including grandchildren) with signal "sig" and return a (gone, still_alive) tuple. "on_terminate", if specified, is a callabck function which is called as soon as a child terminates.

(pid, sig=signal.SIGTERM, include_parent=True,
                   timeout=None, on_terminate=None)

Source from the content-addressed store, hash-verified

19"""
20
21def kill_proc_tree(pid, sig=signal.SIGTERM, include_parent=True,
22 timeout=None, on_terminate=None):
23 """Kill a process tree (including grandchildren) with signal
24 "sig" and return a (gone, still_alive) tuple.
25 "on_terminate", if specified, is a callabck function which is
26 called as soon as a child terminates.
27 """
28 if pid == os.getpid():
29 raise RuntimeError("I refuse to kill myself")
30 parent = psutil.Process(pid)
31 children = parent.children(recursive=True)
32 if include_parent:
33 children.append(parent)
34 for p in children:
35 p.send_signal(sig)
36 gone, alive = psutil.wait_procs(children, timeout=timeout,
37 callback=on_terminate)
38 return (gone, alive)
39
40
41def show_list_by_name(window):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected