diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-12-10 13:44:18 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-12-10 13:44:18 +0100 |
commit | dc544c894eddf90a77d49565673ea7eb216b3e44 (patch) | |
tree | 5ae3b9bd718a18906ab682b5f5a80dfdc8fd87eb /src/run.c | |
parent | dd93edbbd09af4523dfe0f0c3c92f510daf223e8 (diff) | |
download | conntrack-tools-dc544c894eddf90a77d49565673ea7eb216b3e44.tar.gz conntrack-tools-dc544c894eddf90a77d49565673ea7eb216b3e44.zip |
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.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -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) |