summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/run.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/run.c b/src/run.c
index 4bd0e5b..8158f10 100644
--- a/src/run.c
+++ b/src/run.c
@@ -60,7 +60,39 @@ void killer(int foo)
static void child(int foo)
{
- while(wait(NULL) > 0);
+ int status, ret;
+
+ while ((ret = waitpid(0, &status, WNOHANG)) != 0) {
+ if (ret == -1) {
+ if (errno == EINTR)
+ continue;
+ if (errno == ECHILD)
+ break;
+ dlog(LOG_ERR, "wait has failed (%s)", strerror(errno));
+ break;
+ }
+ if (!WIFSIGNALED(status))
+ continue;
+
+ switch(WTERMSIG(status)) {
+ case SIGSEGV:
+ dlog(LOG_ERR, "child process (pid=%u) has aborted, "
+ "received signal SIGSEGV (crashed)", ret);
+ break;
+ case SIGINT:
+ case SIGTERM:
+ case SIGKILL:
+ dlog(LOG_ERR, "child process (pid=%u) has aborted, "
+ "received termination signal (%u)",
+ ret, WTERMSIG(status));
+ break;
+ default:
+ dlog(LOG_NOTICE, "child process (pid=%u) "
+ "received signal (%u)",
+ ret, WTERMSIG(status));
+ break;
+ }
+ }
}
void local_handler(int fd, void *data)