Fix SIGCHLD handling 22/227722/2
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 16 Mar 2020 03:54:43 +0000 (12:54 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 16 Mar 2020 05:55:48 +0000 (14:55 +0900)
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 <y0.cho@samsung.com>
src/core/sig-handler.c

index 527e6f5..dfb8dd1 100644 (file)
@@ -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)