>From 6555f418839a81e215898b2a7d6612d4d642f1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Fri, 3 Mar 2017 00:30:20 -0800 Subject: [PATCH] timeout: handle multiple children on solaris * src/timeout.c (install_sigchld): A new function to install the SIGCHLD handler using sigaction() rather than signal(), because with the latter on solaris the signal handler is reset to default and thus sigsuspend() only returns for the first finished child. Reported by Assaf Gordon. --- src/timeout.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/timeout.c b/src/timeout.c index 6fe0542..2f1ec64 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -324,6 +324,18 @@ parse_duration (const char* str) } static void +install_sigchld (void) +{ + struct sigaction sa; + sigemptyset (&sa.sa_mask); /* Allow concurrent calls to handler */ + sa.sa_handler = chld; + sa.sa_flags = SA_RESTART; /* Restart syscalls if possible, as that's + more likely to work cleanly. */ + + sigaction (SIGCHLD, &sa, NULL); +} + +static void install_cleanup (int sigterm) { struct sigaction sa; @@ -457,7 +469,7 @@ main (int argc, char **argv) install_cleanup (term_signal); signal (SIGTTIN, SIG_IGN); /* Don't stop if background child needs tty. */ signal (SIGTTOU, SIG_IGN); /* Don't stop if background child needs tty. */ - signal (SIGCHLD, chld); /* Interrupt sigsuspend() when child exits. */ + install_sigchld (); /* Interrupt sigsuspend() when child exits. */ monitored_pid = fork (); if (monitored_pid == -1) -- 2.9.3