diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fastd.c | 1 | ||||
-rw-r--r-- | src/shell.c | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/fastd.c b/src/fastd.c index 9761715..2a31da2 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -75,6 +75,7 @@ static void on_sigusr1(int signo UNUSED) { } static void on_sigchld(int signo UNUSED) { + while (waitpid(-1, NULL, WNOHANG) > 0) {} } static void init_signals(fastd_context_t *ctx) { diff --git a/src/shell.c b/src/shell.c index 0b9bef5..8690a1f 100644 --- a/src/shell.c +++ b/src/shell.c @@ -154,12 +154,22 @@ bool fastd_shell_command_exec_sync(fastd_context_t *ctx, const fastd_shell_comma if (!fastd_shell_command_isset(command)) return true; + /* block SIGCHLD */ + sigset_t set, oldset; + sigemptyset(&set); + sigaddset(&set, SIGCHLD); + pthread_sigmask(SIG_BLOCK, &set, &oldset); + pid_t pid; if (!shell_command_do_exec(ctx, command, peer, local_addr, peer_addr, &pid)) return false; int status; - if (waitpid(pid, &status, 0) <= 0) { + pid_t err = waitpid(pid, &status, 0); + + pthread_sigmask(SIG_SETMASK, &oldset, NULL); + + if (err <= 0) { pr_error_errno(ctx, "fastd_shell_command_exec_sync: waitpid"); return false; } |