From: Zdeněk Salvet Date: Mon, 13 Aug 2007 14:35:13 +0000 (+0000) Subject: Report reasons of termination of slaves to debug log (always) and to syslog X-Git-Tag: glite-lb-client_R_3_0_1_1~46 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=17c69ac1c12824a284afe03b318e72d251dff60f;p=jra1mw.git Report reasons of termination of slaves to debug log (always) and to syslog (on errors). --- diff --git a/org.glite.lb.server-bones/src/srvbones.c b/org.glite.lb.server-bones/src/srvbones.c index fdb7ef0..56143c5 100644 --- a/org.glite.lb.server-bones/src/srvbones.c +++ b/org.glite.lb.server-bones/src/srvbones.c @@ -105,6 +105,7 @@ int glite_srvbones_run( struct sigaction sa; sigset_t sset; int sock_slave[2], i; + int pstat; assert(service_table); @@ -174,8 +175,25 @@ int glite_srvbones_run( { int pid; - while ( (pid = waitpid(-1, NULL, WNOHANG)) > 0 ) + while ( (pid = waitpid(-1, &pstat, WNOHANG)) > 0 ) { + if (WIFEXITED(pstat)) { + dprintf(("[master] Slave %d exited with return code %d.\n", pid, WEXITSTATUS(pstat))); + if (WEXITSTATUS(pstat)) { + syslog(LOG_ERR, "Slave %d exited with return code %d.\n", pid, WEXITSTATUS(pstat)); + } + } + if (WIFSIGNALED(pstat)) { + dprintf(("[master] Slave %d terminated with signal %d.\n", pid, WTERMSIG(pstat))); + switch (WTERMSIG(pstat)) { + case SIGINT: + case SIGTERM: + case SIGUSR1: if (die) break; + default: + syslog(LOG_ERR, "Slave %d terminated with signal %d.\n", pid, WTERMSIG(pstat)); + break; + } + } if ( !die ) { int newpid = slave(slave_data_init, sock_slave[1]);