From 2145ee5961cc35d36013e2333c636c7390b6c039 Mon Sep 17 00:00:00 2001 From: Jonathan Schultz Date: Mon, 17 Jul 2017 14:08:58 +1000 Subject: [PATCH] Kill child processes as well as shell process --- gooey/gui/util/taskkill.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gooey/gui/util/taskkill.py b/gooey/gui/util/taskkill.py index a48f676..46e5b57 100644 --- a/gooey/gui/util/taskkill.py +++ b/gooey/gui/util/taskkill.py @@ -7,5 +7,9 @@ if sys.platform.startswith("win"): def taskkill(pid): os.system('taskkill /F /PID {:d} /T >NUL 2>NUL'.format(pid)) else: # POSIX + import psutil def taskkill(pid): - os.kill(pid, signal.SIGTERM) + parent = psutil.Process(pid) + for child in parent.children(recursive=True): + child.kill() + parent.kill()