]> granicus.if.org Git - strace/commitdiff
Fix termination signal forwarding
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 27 May 2017 17:59:44 +0000 (17:59 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 27 May 2017 17:59:44 +0000 (17:59 +0000)
When traced command is terminated by a blocked signal, unblock
that signal to ensure strace termination with the same signal.

* strace.c (main): Unblock the signal raised for strace termination.
* NEWS: Mention this change.

NEWS
strace.c

diff --git a/NEWS b/NEWS
index 5866e69ad285ecad238a64bee1413392c5db647b..20f8640f095ba8bd12248f6d27d6b615f999316a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ Noteworthy changes in release ?.?? (????-??-??)
   * In interactive mode (-I2), those signals that were blocked at startup
     will remain blocked for the whole period of strace execution.
   * strace no longer resets SIGCHLD handler in tracees to the default action.
+  * When traced command is terminated by a blocked signal, strace unblocks
+    that signal to ensure its own termination with the same signal.
 
 Noteworthy changes in release 4.17 (2017-05-24)
 ===============================================
index 473572fad9d776ea56b0c4dfc43714e7fdfe41ff..bdfe1357fd3955d644956b2d05e6eab1bb0fee72 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -2539,6 +2539,13 @@ main(int argc, char *argv[])
                exit_code &= 0xff;
                signal(exit_code, SIG_DFL);
                raise(exit_code);
+
+               /* Unblock the signal.  */
+               sigset_t mask;
+               sigemptyset(&mask);
+               sigaddset(&mask, exit_code);
+               sigprocmask(SIG_UNBLOCK, &mask, NULL);
+
                /* Paranoia - what if this signal is not fatal?
                   Exit with 128 + signo then.  */
                exit_code += 128;