moonbridge

changeset 291:cdf02d09202a

Bugfix in moonbridge.c: Do not use killpg but only terminate each child
author jbe
date Mon Jun 12 13:57:13 2017 +0200 (2017-06-12)
parents 70f047d32a0f
children 7c67bdf99cb5
files moonbridge.c
line diff
     1.1 --- a/moonbridge.c	Sun Jun 11 23:06:26 2017 +0200
     1.2 +++ b/moonbridge.c	Mon Jun 12 13:57:13 2017 +0200
     1.3 @@ -1129,12 +1129,6 @@
     1.4  /* Sets global variable 'moonbr_shutdown_in_progress', closes listeners, and demands worker termination */
     1.5  static void moonbr_initiate_shutdown() {
     1.6    struct moonbr_pool *pool;
     1.7 -  int i;
     1.8 -  static int ignore_once = 0;
     1.9 -  if (ignore_once) {
    1.10 -    ignore_once = 0;
    1.11 -    return;
    1.12 -  }
    1.13    if (moonbr_shutdown_in_progress) {
    1.14      moonbr_log(LOG_NOTICE, "Shutdown already in progress");
    1.15      return;
    1.16 @@ -1142,6 +1136,7 @@
    1.17    moonbr_shutdown_in_progress = 1;
    1.18    moonbr_log(LOG_NOTICE, "Initiate shutdown");
    1.19    for (pool = moonbr_first_pool; pool; pool = pool->next_pool) {
    1.20 +    int i;
    1.21      for (i=0; i<pool->listener_count; i++) {
    1.22        struct moonbr_listener *listener = &pool->listener[i];
    1.23        if (listener->listenfd != -1) {
    1.24 @@ -1153,13 +1148,16 @@
    1.25      }
    1.26    }
    1.27    moonbr_poll_shutdown();  /* avoids loops due to error condition when polling closed listeners */
    1.28 -  {
    1.29 -    pid_t pgrp = getpgrp();
    1.30 -    moonbr_log(LOG_INFO, "Sending SIGTERM to all processes in group %i", (int)pgrp);
    1.31 -    if (killpg(pgrp, SIGTERM)) {
    1.32 -      moonbr_log(LOG_WARNING, "Error while sending SIGTERM to own process group: %s", strerror(errno));
    1.33 +  for (pool=moonbr_first_pool; pool; pool=pool->next_pool) {
    1.34 +    struct moonbr_worker *worker;
    1.35 +    for (worker=pool->first_worker; worker; worker=worker->next_worker) {
    1.36 +      if (moonbr_debug) {
    1.37 +        moonbr_log(LOG_DEBUG, "Sending SIGTERM to child with PID %i", (int)worker->pid);
    1.38 +      }
    1.39 +      if (kill(worker->pid, SIGTERM)) {
    1.40 +        moonbr_log(LOG_ERR, "Error while terminating child process: %s", strerror(errno));
    1.41 +      }
    1.42      }
    1.43 -    ignore_once = 1;
    1.44    }
    1.45  }
    1.46  

Impressum / About Us