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

Function kill_proc

DemoPrograms/Demo_psutil_Kill_Python_Processes.py:48–58  ·  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

46
47
48def kill_proc(pid, sig=signal.SIGTERM, include_parent=True,
49 timeout=None, on_terminate=None):
50 """Kill a process tree (including grandchildren) with signal
51 "sig" and return a (gone, still_alive) tuple.
52 "on_terminate", if specified, is a callabck function which is
53 called as soon as a child terminates.
54 """
55 if pid == os.getpid():
56 raise RuntimeError("I refuse to kill myself")
57 parent = psutil.Process(pid)
58 parent.send_signal(sig)
59
60
61def get_all_procs():

Callers 2

kill_allFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected