diff --git a/build/main.c b/build/main.c index f8ade32c..d5fec663 100644 --- a/build/main.c +++ b/build/main.c @@ -375,6 +375,11 @@ static void start_mongoose(int argc, char *argv[]) { signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); +#if !defined(_WIN32) + // Also ignoring SIGCHLD to let the OS to reap zombies properly. + (void) signal(SIGCHLD, SIG_IGN); +#endif + // Start Mongoose memset(&callbacks, 0, sizeof(callbacks)); callbacks.log_message = &log_message; diff --git a/mongoose.c b/mongoose.c index 952b4ce7..42a7c0c6 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5452,8 +5452,6 @@ struct mg_context *mg_start(const struct mg_callbacks *callbacks, // Ignore SIGPIPE signal, so if browser cancels the request, it // won't kill the whole process. (void) signal(SIGPIPE, SIG_IGN); - // Also ignoring SIGCHLD to let the OS to reap zombies properly. - (void) signal(SIGCHLD, SIG_IGN); #endif // !_WIN32 (void) pthread_mutex_init(&ctx->mutex, NULL); diff --git a/mongoose.h b/mongoose.h index 553d8833..6b7e758e 100644 --- a/mongoose.h +++ b/mongoose.h @@ -142,10 +142,12 @@ struct mg_callbacks { // options: NULL terminated list of option_name, option_value pairs that // specify Mongoose configuration parameters. // -// Side-effects: on UNIX, ignores SIGCHLD and SIGPIPE signals. If custom -// processing is required for these, signal handlers must be set up +// Side-effects: on UNIX, ignores SIGPIPE signals. If custom +// processing is required SIGPIPE, signal handler must be set up // after calling mg_start(). // +// Important: Mongoose does not install SIGCHLD handler. If CGI is used, +// SIGCHLD handler must be set up to reap CGI zombie processes. // // Example: // const char *options[] = {