[conntrack-tools] run: better wait() error handling
Pablo Neira
netfilter-cvslog-bounces at lists.netfilter.org
Wed Dec 10 17:00:02 CET 2008
Gitweb: http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=dc544c894eddf90a77d49565673ea7eb216b3e44
commit dc544c894eddf90a77d49565673ea7eb216b3e44
Author: Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Wed Dec 10 13:44:18 2008 +0100
Commit: Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Wed Dec 10 13:44:18 2008 +0100
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 at netfilter.org>
via dc544c894eddf90a77d49565673ea7eb216b3e44 (commit)
from dd93edbbd09af4523dfe0f0c3c92f510daf223e8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit dc544c894eddf90a77d49565673ea7eb216b3e44
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date: Wed Dec 10 13:44:18 2008 +0100
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 at netfilter.org>
-----------------------------------------------------------------------
src/run.c | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
The current wait() error handling was insufficient. This patch
introduce more verbose error reporting.
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
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)
More information about the netfilter-cvslog
mailing list