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.
This commit is contained in:
Дмитрий Левин 2017-05-27 17:59:44 +00:00
parent e97a66faa1
commit 47b93f2a7a
2 changed files with 9 additions and 0 deletions

2
NEWS
View File

@ -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)
===============================================

View File

@ -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;