diff --git a/NEWS b/NEWS index 2878b702d..c3128e145 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,10 @@ GNU coreutils NEWS -*- outline -*- to attempt to hide the original length of the file name. [bug introduced in coreutils-8.28] + timeout will again notice its managed command exiting, even when + invoked with blocked CHLD signal. + [bug introduced in coreutils-8.27] + ** Build-related Default man pages are now distributed which are used if perl is diff --git a/src/timeout.c b/src/timeout.c index a58b84f4e..9be70e015 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -323,6 +323,16 @@ parse_duration (const char* str) return duration; } +static void +unblock_signal (int sig) +{ + sigset_t unblock_set; + sigemptyset (&unblock_set); + sigaddset (&unblock_set, sig); + if (sigprocmask (SIG_UNBLOCK, &unblock_set, NULL) != 0) + error (0, errno, _("warning: sigprocmask")); +} + static void install_sigchld (void) { @@ -333,6 +343,10 @@ install_sigchld (void) more likely to work cleanly. */ sigaction (SIGCHLD, &sa, NULL); + + /* We inherit the signal mask from our parent process, + so ensure SIGCHLD is not blocked. */ + unblock_signal (SIGCHLD); } static void @@ -369,16 +383,6 @@ block_cleanup (int sigterm, sigset_t *old_set) error (0, errno, _("warning: sigprocmask")); } -static void -unblock_signal (int sig) -{ - sigset_t unblock_set; - sigemptyset (&unblock_set); - sigaddset (&unblock_set, sig); - if (sigprocmask (SIG_UNBLOCK, &unblock_set, NULL) != 0) - error (0, errno, _("warning: sigprocmask")); -} - /* Try to disable core dumps for this process. Return TRUE if successful, FALSE otherwise. */ static bool