aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mtest.py
diff options
context:
space:
mode:
authorRobert Doolittle <rdoolittle@gmail.com>2018-01-30 10:13:34 -0800
committerRobert Doolittle <rdoolittle@gmail.com>2018-01-30 10:13:34 -0800
commit60cfb87e69502a6083ce46f15edf46c27a2e92ba (patch)
tree9f46e9ec2568f157c3ba14ef0cbdbc2fbfe3d18b /mesonbuild/mtest.py
parent2cf85ae16f79b5edcbfa34d57b477c984c79e7a5 (diff)
downloadmeson-60cfb87e69502a6083ce46f15edf46c27a2e92ba.zip
meson-60cfb87e69502a6083ce46f15edf46c27a2e92ba.tar.gz
meson-60cfb87e69502a6083ce46f15edf46c27a2e92ba.tar.bz2
mtest: catch ctrl-c and properly kill the child processes. Fixes #2281
Diffstat (limited to 'mesonbuild/mtest.py')
-rw-r--r--mesonbuild/mtest.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 2032e05..61ab3dd 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -241,8 +241,8 @@ class TestHarness:
stdout = subprocess.PIPE
stderr = subprocess.PIPE if self.options and self.options.split else subprocess.STDOUT
- if not is_windows():
- setsid = os.setsid
+ if not is_windows():
+ setsid = os.setsid
p = subprocess.Popen(cmd,
stdout=stdout,
@@ -251,6 +251,7 @@ class TestHarness:
cwd=test.workdir,
preexec_fn=setsid)
timed_out = False
+ kill_test = False
if test.timeout is None:
timeout = None
else:
@@ -261,6 +262,14 @@ class TestHarness:
if self.options.verbose:
print("%s time out (After %d seconds)" % (test.name, timeout))
timed_out = True
+ except KeyboardInterrupt:
+ mlog.warning("CTRL-C detected while running %s" % (test.name))
+ kill_test = True
+ except:
+ mlog.warning("Unknown error while running %s" % (test.name))
+ kill_test = True
+
+ if kill_test or timed_out:
# Python does not provide multiplatform support for
# killing a process and all its children so we need
# to roll our own.