From 7d921ad80050356a8795d9fcaa1d5aa0c51159ee Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 2 Jan 2016 00:35:12 +0100 Subject: fix bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/satd-diminished.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/satd-diminished.c b/src/satd-diminished.c index 5404327..811c545 100644 --- a/src/satd-diminished.c +++ b/src/satd-diminished.c @@ -74,18 +74,19 @@ static const struct itimerspec nilspec = { static void sighandler(int signo) { - int saved_errno = errno; + int no_reap = 1, saved_errno = errno; pid_t pid; if (signo == SIGCHLD) { for (; (pid = waitpid(-1, NULL, WNOHANG)) > 0; child_count--) { + no_reap = 0; if (pid == timer_pid) timer_pid = NO_TIMER_SPAWNED; else received_signo = (sig_atomic_t)signo; } - } else { - received_signo = (sig_atomic_t)signo; } + if (no_reap) /* Phony SIGCHLD or not SIGCHLD at all. */ + received_signo = (sig_atomic_t)signo; errno = saved_errno; } @@ -187,8 +188,8 @@ again: perror(argv[0]); } /* Need to set new timer values? */ - if (expired || ((received_signo == SIGCHLD) && !child_count)) - t (expired = 0, spawn(argv, envp)); + if ((received_signo == SIGCHLD) && !child_count) + t (spawn(argv, envp)); received_signo = 0; #if 1 || !defined(DEBUG) /* Can we quit yet? */ -- cgit v1.2.3-70-g09d2