From 8945c53711c92f2fb48cfab94870e3cf759f3a35 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 18 Oct 2021 19:15:00 +0200 Subject: mtest: limit "magic" CTRL+C behavior to process group leaders If meson is not a process group leader, a SIGINT will be delivered also to its parent process (and possibly other processes). The parent process then will probably exit and mtest will continue running in the background, without any way to interrupt the run completely. To fix this, treat SIGINT and SIGTERM the same way unless mtest is a process group leader. Signed-off-by: Paolo Bonzini --- mesonbuild/mtest.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 36c4da982..74d7d8bf1 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -1893,7 +1893,10 @@ class TestHarness: l.start(self) if sys.platform != 'win32': - asyncio.get_event_loop().add_signal_handler(signal.SIGINT, sigint_handler) + if os.getpgid(0) == os.getpid(): + asyncio.get_event_loop().add_signal_handler(signal.SIGINT, sigint_handler) + else: + asyncio.get_event_loop().add_signal_handler(signal.SIGINT, sigterm_handler) asyncio.get_event_loop().add_signal_handler(signal.SIGTERM, sigterm_handler) try: for runner in runners: -- cgit v1.2.3