From: Fredrik Tolf Date: Thu, 8 Mar 2012 23:57:36 +0000 (+0100) Subject: callcgi: Properly wait for the handler process to exit. X-Git-Tag: 0.11~28 X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=commitdiff_plain;h=3349651ff4e863cd197f7bab667bbd16aa9ff905 callcgi: Properly wait for the handler process to exit. --- diff --git a/src/callcgi.c b/src/callcgi.c index 3add3ed..31c41fb 100644 --- a/src/callcgi.c +++ b/src/callcgi.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include @@ -343,6 +344,7 @@ int main(int argc, char **argv, char **envp) FILE *in, *out; char **headers; pid_t child; + int estat; environ = envp; signal(SIGPIPE, SIG_IGN); @@ -404,5 +406,14 @@ int main(int argc, char **argv, char **envp) printf("\n"); if(passdata(out, stdout)) kill(child, SIGINT); - return(0); + if(waitpid(child, &estat, 0) == child) { + if(WCOREDUMP(estat)) + flog(LOG_WARNING, "CGI handler `%s' dumped core", prog); + if(WIFEXITED(estat) && !WEXITSTATUS(estat)) + return(0); + else + return(1); + } + flog(LOG_WARNING, "could not wait for CGI handler: %s", strerror(errno)); + return(1); }