summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlicia Boya GarcĂ­a <ntrrgc@gmail.com>2018-05-25 12:03:46 +0200
committerThibault Saunier <tsaunier@igalia.com>2018-05-25 12:59:41 +0200
commit40dfb7174e329be12dea5a57301db0538ca9933b (patch)
tree4c9359d06c395cf07a10f1f8e99ad9ba7fac82b6
parentbfa143caa92674b5c3d44e5c73cf05db45988a84 (diff)
gst-validate-launcher: let gdb handle SIGINT itself
Otherwise both gdb and gst-validate-launcher will react to ^C at the same time, gdb will be killed by SIGHUP (because gst-validate-launcher quitted in consequence of the ^C) and the terminal state will be left garbled because readline inside gdb had disabled echo. https://bugzilla.gnome.org/show_bug.cgi?id=796396
-rw-r--r--validate/launcher/baseclasses.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/validate/launcher/baseclasses.py b/validate/launcher/baseclasses.py
index bac3336..41f66ad 100644
--- a/validate/launcher/baseclasses.py
+++ b/validate/launcher/baseclasses.py
@@ -360,11 +360,22 @@ class Test(Loggable):
pass
def thread_wrapper(self):
+ def enable_sigint():
+ # Restore the SIGINT handler for the child process (gdb) to ensure
+ # it can handle it.
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+
+ if self.options.gdb and os.name != "nt":
+ preexec_fn = enable_sigint
+ else:
+ preexec_fn = None
+
self.process = subprocess.Popen(self.command,
stderr=self.out,
stdout=self.out,
env=self.proc_env,
- cwd=self.workdir)
+ cwd=self.workdir,
+ preexec_fn=preexec_fn)
self.process.wait()
if self.result is not Result.TIMEOUT:
if self.process.returncode == 0:
@@ -492,6 +503,11 @@ class Test(Loggable):
if self.options.gdb:
self.command = self.use_gdb(self.command)
+
+ self.previous_sigint_handler = signal.getsignal(signal.SIGINT)
+ # Make the gst-validate executable ignore SIGINT while gdb is running.
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+
if self.options.valgrind:
self.command = self.use_valgrind(self.command, self.proc_env)
@@ -533,6 +549,9 @@ class Test(Loggable):
self.thread.join()
self.time_taken = time.time() - self._starting_time
+ if self.options.gdb:
+ signal.signal(signal.SIGINT, self.previous_sigint_handler)
+
if self.result != Result.PASSED:
message = str(self)
end = "\n"