From 47b93f2a7a6b0eb295a22431b699a36676d6e3af Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 27 May 2017 17:59:44 +0000 Subject: [PATCH] Fix termination signal forwarding 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 | 2 ++ strace.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/NEWS b/NEWS index 5866e69a..20f8640f 100644 --- 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) =============================================== diff --git a/strace.c b/strace.c index 473572fa..bdfe1357 100644 --- 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; -- 2.40.0