summaryrefslogtreecommitdiffstats
path: root/src/run.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-12-10 13:44:18 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-12-10 13:44:18 +0100
commitdc544c894eddf90a77d49565673ea7eb216b3e44 (patch)
tree5ae3b9bd718a18906ab682b5f5a80dfdc8fd87eb /src/run.c
parentdd93edbbd09af4523dfe0f0c3c92f510daf223e8 (diff)
run: better wait() error handling
The current wait() error handling was insufficient. This patch introduce more verbose error reporting. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/run.c')
-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)