diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-28 18:08:20 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-28 18:08:20 +0100 |
commit | 8b66b00d8b2362d6799d7fad1920e65339e2e5e8 (patch) | |
tree | 932aec65784921792e99afa67953fb4f895510ef | |
parent | m (diff) | |
download | sat-8b66b00d8b2362d6799d7fad1920e65339e2e5e8.tar.gz sat-8b66b00d8b2362d6799d7fad1920e65339e2e5e8.tar.bz2 sat-8b66b00d8b2362d6799d7fad1920e65339e2e5e8.tar.xz |
reap children in sighandler to avoid getting stuck at EAGAIN
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r-- | src/satd-diminished.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/satd-diminished.c b/src/satd-diminished.c index f2e039f..187ad6a 100644 --- a/src/satd-diminished.c +++ b/src/satd-diminished.c @@ -87,7 +87,16 @@ static volatile sig_atomic_to received_signo = 0; */ static void sighander(int signo) { - received_signo = (sig_atomic_to)signo; + int saved_errno = errno; + switch (signo) { + case SIGCHLD: + waitpid(-1, NULL, WNOHANG); + break; + default: + received_signo = (sig_atomic_to)signo; + break; + } + errno = saved_errno; } @@ -126,7 +135,6 @@ main(int argc, char *argv[], char *envp[]) /* The magnificent loop. */ accept_again: - while (waitpid(-1, NULL, WNOHANG) > 0); if (received_signo == SIGHUP) { execve(DAEMON_PREFIX "diminished", argv, envp); perror(argv[0]); |