Index: main.c ================================================================== --- main.c +++ main.c @@ -156,10 +156,11 @@ static int do_vhost(struct event_base *, struct vhost *, int); static struct evhttp_uri * get_clean_uri(struct evhttp_request *); static int get_fs_path(struct evhttp_request *, struct vhost *, struct mohawk_path *, char *, struct stat *); static void handle_sigterm(int sig); +static void handle_sigchld(int sig); static void mohawk_event_log_cb(int, const char *); static time_t parse_date(const char *); static void request_decode_paths(struct mohawk_path *); static int request_index_lookup(struct vhost *, const char *, char **, struct stat *); @@ -1665,10 +1666,20 @@ syslog(LOG_NOTICE, "exiting due to signal %d", sig); closelog(); errx(EXIT_FAILURE, "exiting due to signal %d", sig); } + +static void +handle_sigchld(int sig) +{ + (void)sig; + pid_t pid; + int status; + + while((pid = waitpid(-1, &status, WNOHANG)) > 0); +} static void mohawk_event_log_cb(int severity, const char *msg) { if (conf.debug) @@ -1788,11 +1799,11 @@ #if defined(__FreeBSD__) pid_t otherpid; #endif uid_t uid = 65534; gid_t gid = 65534; - struct sigaction act_pipe, act_handler; + struct sigaction act_pipe, act_handler, act_chld; /* configuration initialization */ #if defined(HAVE_BLACKLISTD) conf.blacklistd = 0; #endif @@ -2056,10 +2067,17 @@ /* without, if client close the socket, our daemon die */ act_pipe.sa_handler = SIG_IGN; act_pipe.sa_flags = 0; sigemptyset(&act_pipe.sa_mask); sigaction(SIGPIPE, &act_pipe, NULL); + + /* Handle SIGCHLD properly for cgi */ + sigemptyset(&act_chld.sa_mask); + act_chld.sa_flags = 0; + act_chld.sa_handler = handle_sigchld; + sigaction(SIGCHLD, &act_chld, NULL); + /* if error errno is set */ ret = event_base_dispatch(eb); /* TODO: free each http virtual host */