# HG changeset patch # User jbe # Date 1497268633 -7200 # Node ID cdf02d09202a6543482586fd22436ae86c8a47fd # Parent 70f047d32a0f8e553a2fad1d7f5181d3b7d9d681 Bugfix in moonbridge.c: Do not use killpg but only terminate each child diff -r 70f047d32a0f -r cdf02d09202a moonbridge.c --- a/moonbridge.c Sun Jun 11 23:06:26 2017 +0200 +++ b/moonbridge.c Mon Jun 12 13:57:13 2017 +0200 @@ -1129,12 +1129,6 @@ /* Sets global variable 'moonbr_shutdown_in_progress', closes listeners, and demands worker termination */ static void moonbr_initiate_shutdown() { struct moonbr_pool *pool; - int i; - static int ignore_once = 0; - if (ignore_once) { - ignore_once = 0; - return; - } if (moonbr_shutdown_in_progress) { moonbr_log(LOG_NOTICE, "Shutdown already in progress"); return; @@ -1142,6 +1136,7 @@ moonbr_shutdown_in_progress = 1; moonbr_log(LOG_NOTICE, "Initiate shutdown"); for (pool = moonbr_first_pool; pool; pool = pool->next_pool) { + int i; for (i=0; ilistener_count; i++) { struct moonbr_listener *listener = &pool->listener[i]; if (listener->listenfd != -1) { @@ -1153,13 +1148,16 @@ } } moonbr_poll_shutdown(); /* avoids loops due to error condition when polling closed listeners */ - { - pid_t pgrp = getpgrp(); - moonbr_log(LOG_INFO, "Sending SIGTERM to all processes in group %i", (int)pgrp); - if (killpg(pgrp, SIGTERM)) { - moonbr_log(LOG_WARNING, "Error while sending SIGTERM to own process group: %s", strerror(errno)); + for (pool=moonbr_first_pool; pool; pool=pool->next_pool) { + struct moonbr_worker *worker; + for (worker=pool->first_worker; worker; worker=worker->next_worker) { + if (moonbr_debug) { + moonbr_log(LOG_DEBUG, "Sending SIGTERM to child with PID %i", (int)worker->pid); + } + if (kill(worker->pid, SIGTERM)) { + moonbr_log(LOG_ERR, "Error while terminating child process: %s", strerror(errno)); + } } - ignore_once = 1; } }