X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fpatplex.c;h=bf4fda9ad3058a3ffe9d36a983c0e5b3ba4294dc;hb=90b0ba0f9d93e454cc08a566b718abdcbfd0d9f6;hp=d296e04f8c407f8ded35e849035a8d5ae3b95e69;hpb=6174a0392d661ea7cba3cd90ff35ced3b518ca87;p=ashd.git diff --git a/src/patplex.c b/src/patplex.c index d296e04..bf4fda9 100644 --- a/src/patplex.c +++ b/src/patplex.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include @@ -438,32 +439,32 @@ 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."); } static void reloadconf(char *nm) { struct config *cf; - struct child *ch1, *ch2; if((cf = readconfig(nm)) == NULL) { flog(LOG_WARNING, "could not reload configuration file `%s'", nm); return; } - for(ch1 = cf->children; ch1 != NULL; ch1 = ch1->next) { - for(ch2 = lconfig->children; ch2 != NULL; ch2 = ch2->next) { - if(!strcmp(ch1->name, ch2->name)) { - ch1->fd = ch2->fd; - ch2->fd = -1; - break; - } - } - } + mergechildren(cf->children, lconfig->children); freeconfig(lconfig); 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,8 +512,9 @@ 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]);