From 3d6044aba083ec8fa366bf85794a9ae62eab9858 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Wed, 21 Mar 2012 00:32:49 +0100 Subject: [PATCH] Warn for core dumps in various places. --- src/dirplex/dirplex.c | 8 +++++--- src/htextauth.c | 2 ++ src/multifscgi.c | 4 ++++ src/patplex.c | 8 +++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/dirplex/dirplex.c b/src/dirplex/dirplex.c index 14320ad..55b4648 100644 --- a/src/dirplex/dirplex.c +++ b/src/dirplex/dirplex.c @@ -320,10 +320,12 @@ static void serve(struct hthead *req, int fd) static void chldhandler(int sig) { pid_t pid; + int st; - do { - pid = waitpid(-1, NULL, WNOHANG); - } while(pid > 0); + while((pid = waitpid(-1, &st, WNOHANG)) > 0) { + if(WCOREDUMP(st)) + flog(LOG_WARNING, "child process %i dumped core", pid); + } } static void sighandler(int sig) diff --git a/src/htextauth.c b/src/htextauth.c index 4a7e29d..c12e1a4 100644 --- a/src/htextauth.c +++ b/src/htextauth.c @@ -285,6 +285,8 @@ static int auth(struct hthead *req, int fd, char *user, char *pass) buffree(ebuf); return(0); } + if(WCOREDUMP(status)) + flog(LOG_WARNING, "htextauth: authenticator process dumped core"); if(WIFEXITED(status) && (WEXITSTATUS(status) == 0)) rv = 1; else diff --git a/src/multifscgi.c b/src/multifscgi.c index 6cc232f..a865ec7 100644 --- a/src/multifscgi.c +++ b/src/multifscgi.c @@ -66,6 +66,8 @@ static void manage(void) pselect(0, NULL, NULL, NULL, NULL, &ns); if(chdone) { while((ch = waitpid(-1, &st, WNOHANG)) > 0) { + if(WCOREDUMP(st)) + fprintf(stderr, "multifscgi: child %i (%s) dumped core\n", ch, chspec[0]); for(i = 0; i < nchildren; i++) { if(children[i] == ch) children[i] = 0; @@ -108,6 +110,8 @@ static void killall(void) pselect(0, NULL, NULL, NULL, &to, &ns); if(chdone) { while((ch = waitpid(-1, &st, WNOHANG)) > 0) { + if(WCOREDUMP(st)) + fprintf(stderr, "multifscgi: child %i (%s) dumped core\n", ch, chspec[0]); for(i = 0; i < nchildren; i++) { if(children[i] == ch) children[i] = 0; diff --git a/src/patplex.c b/src/patplex.c index 5506386..13fa062 100644 --- a/src/patplex.c +++ b/src/patplex.c @@ -491,10 +491,12 @@ static void reloadconf(char *nm) static void chldhandler(int sig) { pid_t pid; + int st; - do { - pid = waitpid(-1, NULL, WNOHANG); - } while(pid > 0); + while((pid = waitpid(-1, &st, WNOHANG)) > 0) { + if(WCOREDUMP(st)) + flog(LOG_WARNING, "child process %i dumped core", pid); + } } static void sighandler(int sig) -- 2.11.0