X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=blobdiff_plain;f=signal.c;h=2685d0bdd2a723a05504af89c9cdb16567e84dfa;hp=c82e58b29af65fff20b77d5180217cd9c01b8bea;hb=cfdc28028a7a55a1f9e14ff3d2e34273ef32e6a6;hpb=2a2d1f8d52477af7e6e161d60c722b7a2f1a4651 diff --git a/signal.c b/signal.c index c82e58b..2685d0b 100644 --- a/signal.c +++ b/signal.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "gcc-compat.h" @@ -86,21 +87,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; @@ -121,7 +121,6 @@ int install_sighandler(int sig) DSS_DEBUG_LOG("catching signal %d\n", sig); if (signal(sig, &generic_signal_handler) != SIG_ERR) return 1; - make_err_msg("signal %d", sig); return -E_SIGNAL_SIG_ERR; } @@ -148,7 +147,7 @@ int next_signal(void) assert(r < 0); if (err == EAGAIN) return 0; - make_err_msg("failed to read from signal pipe"); + DSS_ERROR_LOG("failed to read from signal pipe\n"); return -ERRNO_TO_DSS_ERROR(err); }