From e5140e4e43943caf732a4db3394a58e2a6507ce0 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 16 Mar 2020 12:54:43 +0900 Subject: [PATCH] Fix SIGCHLD handling Don't treat ECHILD as an error case as it means this SIGCHLD had already been handled somewhere else. Change-Id: I115c942b5ec616bf21873e806b6f97add959f054 Signed-off-by: Youngjae Cho --- src/core/sig-handler.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/core/sig-handler.c b/src/core/sig-handler.c index 527e6f5..dfb8dd1 100644 --- a/src/core/sig-handler.c +++ b/src/core/sig-handler.c @@ -30,19 +30,17 @@ static struct sigaction sig_pipe_old_act; static void sig_child_handler(int signo, siginfo_t *info, void *data) { - pid_t pid; + pid_t ret; int status; if (!info || signo != SIGCHLD) return; - pid = waitpid(info->si_pid, &status, 0); - if (pid == -1) { - _E("SIGCHLD received.\n"); - return; - } - - _D("Sig child actend call - %d\n", info->si_pid); + ret = waitpid(info->si_pid, &status, 0); + if (ret >= 0) + _D("SIGCHLD from %d handled successfully.", ret); + else if (ret == -1 && errno != ECHILD) + _E("Failed to handle SIGCHLD(%d).", errno); } static void sig_pipe_handler(int signo, siginfo_t *info, void *data) -- 2.7.4