summaryrefslogtreecommitdiffstats
path: root/src/shell.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-18 16:50:32 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-18 16:50:32 +0200
commite6ad38a5409b18b573a59177ea8bb21c22747964 (patch)
tree4b82facd067e128bec96b8cd8443fe5148198e57 /src/shell.c
parent87dd930beddef23e7278df476584d9071b76929c (diff)
downloadfastd-e6ad38a5409b18b573a59177ea8bb21c22747964.tar
fastd-e6ad38a5409b18b573a59177ea8bb21c22747964.zip
Fix zombie process cleanup
Diffstat (limited to 'src/shell.c')
-rw-r--r--src/shell.c12
1 files changed, 11 insertions, 1 deletions
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;
}