mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-24 20:21:49 +00:00
Reaping zombies properly
This commit is contained in:
1 parent
1777cc6e86
commit
3adaf8dba9
1 file changed
+7
@@ -78,11 +78,15 @@ static struct mg_context *ctx; // Set by start_mongoose()
|
|||||||
#endif /* !CONFIG_FILE */
|
#endif /* !CONFIG_FILE */
|
||||||
|
|
||||||
static void WINCDECL signal_handler(int sig_num) {
|
static void WINCDECL signal_handler(int sig_num) {
|
||||||
|
// Reinstantiate signal handler
|
||||||
|
signal(sig_num, signal_handler);
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
// Do not do the trick with ignoring SIGCHLD, cause not all OSes (e.g. QNX)
|
// Do not do the trick with ignoring SIGCHLD, cause not all OSes (e.g. QNX)
|
||||||
// reap zombies if SIGCHLD is ignored. On QNX, for example, waitpid()
|
// reap zombies if SIGCHLD is ignored. On QNX, for example, waitpid()
|
||||||
// fails if SIGCHLD is ignored, making system() non-functional.
|
// fails if SIGCHLD is ignored, making system() non-functional.
|
||||||
if (sig_num == SIGCHLD) {
|
if (sig_num == SIGCHLD) {
|
||||||
|
printf("dssfdsfds\n");
|
||||||
do {} while (waitpid(-1, &sig_num, WNOHANG) > 0);
|
do {} while (waitpid(-1, &sig_num, WNOHANG) > 0);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@@ -383,6 +387,9 @@ static void start_mongoose(int argc, char *argv[]) {
|
|||||||
// Setup signal handler: quit on Ctrl-C
|
// Setup signal handler: quit on Ctrl-C
|
||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
signal(SIGINT, signal_handler);
|
signal(SIGINT, signal_handler);
|
||||||
|
#ifndef _WIN32
|
||||||
|
signal(SIGCHLD, signal_handler);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Start Mongoose
|
// Start Mongoose
|
||||||
ctx = mg_start((const char **) options, event_handler, NULL);
|
ctx = mg_start((const char **) options, event_handler, NULL);
|
||||||
|
|||||||
Reference in new issue
Block a user