X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=blobdiff_plain;f=signal.c;h=03926a47f23e29e40a3a8bf6dccccd5b460b96c0;hp=c82e58b29af65fff20b77d5180217cd9c01b8bea;hb=a0b87ba0529cc6ab075e1d7a11f8b4adc47948eb;hpb=8f1fcd9c5ea3aa0f78be83b2a912a1e8cf722b76 diff --git a/signal.c b/signal.c index c82e58b..03926a4 100644 --- a/signal.c +++ b/signal.c @@ -86,21 +86,20 @@ static void generic_signal_handler(int s) * * \sa waitpid(2) */ -int reap_child(pid_t *pid) +int reap_child(pid_t *pid, int *status) { - int status; - *pid = waitpid(-1, &status, WNOHANG); + *pid = waitpid(-1, status, WNOHANG); if (!*pid) return 0; if (*pid < 0) return -ERRNO_TO_DSS_ERROR(errno); - if (WIFEXITED(status)) + if (WIFEXITED(*status)) DSS_DEBUG_LOG("child %i exited. Exit status: %i\n", (int)*pid, - WEXITSTATUS(status)); - else if (WIFSIGNALED(status)) + WEXITSTATUS(*status)); + else if (WIFSIGNALED(*status)) DSS_DEBUG_LOG("child %i was killed by signal %i\n", (int)*pid, - WTERMSIG(status)); + WTERMSIG(*status)); else DSS_WARNING_LOG("child %i terminated abormally\n", (int)*pid); return 1;