X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fpatplex.c;h=3b3d7f9a5741855c53e7f97e8f7cf928ecebc0a0;hb=46db3a23a845ee5e8e95f4149632dda24e0f8003;hp=3f22d738b582e0263bdfb3f08cf24d0579fac5c2;hpb=3a42b6b1d0b8f9e8ce5c77e838e2573bbfabe593;p=ashd.git diff --git a/src/patplex.c b/src/patplex.c index 3f22d73..3b3d7f9 100644 --- a/src/patplex.c +++ b/src/patplex.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include @@ -438,7 +439,7 @@ static void serve(struct hthead *req, int fd) return; } - if(childhandle(ch, req, fd)) + if(childhandle(ch, req, fd, NULL, NULL)) simpleerror(fd, 500, "Server Error", "The request handler crashed."); } @@ -464,6 +465,15 @@ static void reloadconf(char *nm) lconfig = cf; } +static void chldhandler(int sig) +{ + pid_t pid; + + do { + pid = waitpid(-1, NULL, WNOHANG); + } while(pid > 0); +} + static void sighandler(int sig) { if(sig == SIGHUP) @@ -511,14 +521,17 @@ int main(int argc, char **argv) flog(LOG_ERR, "could not read `%s'", argv[optind]); exit(1); } - signal(SIGCHLD, SIG_IGN); + signal(SIGCHLD, chldhandler); signal(SIGHUP, sighandler); + signal(SIGPIPE, sighandler); while(1) { if(reload) { reloadconf(argv[optind]); reload = 0; } if((fd = recvreq(0, &req)) < 0) { + if(errno == EINTR) + continue; if(errno != 0) flog(LOG_ERR, "recvreq: %s", strerror(errno)); break;