X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fsighandlers.c;h=a219105f4b5aff571e045f22d58f0f5fc4d17162;hp=d472b7fcbb1c165e269c57d9dde761ec65835928;hb=808c291c76b7ecb4ae13b6ee12e8afe658b627c1;hpb=74578890b71dc16aadaf299af875b45fc7fbe081 diff --git a/src/ngircd/sighandlers.c b/src/ngircd/sighandlers.c index d472b7fc..a219105f 100644 --- a/src/ngircd/sighandlers.c +++ b/src/ngircd/sighandlers.c @@ -36,6 +36,10 @@ static int signalpipe[2]; +static const int signals_catch[] = { + SIGINT, SIGQUIT, SIGTERM, SIGHUP, SIGCHLD, SIGUSR1, SIGUSR2 +}; + #ifdef DEBUG @@ -86,11 +90,12 @@ Signal_Unblock(int sig) #endif } + /** * Reload the server configuration file. */ static void -NGIRCd_Rehash( void ) +Rehash(void) { char old_name[CLIENT_ID_LEN]; unsigned old_nicklen; @@ -132,8 +137,7 @@ NGIRCd_Rehash( void ) Conn_SyncServerStruct( ); Log( LOG_NOTICE|LOG_snotice, "Re-reading of configuration done." ); -} /* NGIRCd_Rehash */ - +} /* Rehash */ /** @@ -154,8 +158,6 @@ Signal_Handler(int Signal) /* shut down sever */ NGIRCd_SignalQuit = true; return; - case SIGHUP: - break; case SIGCHLD: /* child-process exited, avoid zombies */ while (waitpid( -1, NULL, WNOHANG) > 0) @@ -212,12 +214,15 @@ Signal_Handler_BH(int Signal) switch (Signal) { case SIGHUP: /* re-read configuration */ - NGIRCd_Rehash(); + Rehash(); break; #ifdef DEBUG case SIGUSR2: - if (NGIRCd_Debug) + if (NGIRCd_Debug) { + Log(LOG_INFO|LOG_snotice, + "Got SIGUSR2, dumping internal state ..."); Dump_State(); + } break; default: Log(LOG_DEBUG, "Got signal %d! Ignored.", Signal); @@ -234,7 +239,7 @@ Signal_Callback(int fd, short UNUSED what) (void) what; do { - ret = read(fd, &sig, sizeof(sig)); + ret = (int)read(fd, &sig, sizeof(sig)); if (ret == sizeof(int)) Signal_Handler_BH(sig); } while (ret == sizeof(int)); @@ -252,7 +257,6 @@ Signal_Callback(int fd, short UNUSED what) } -static const int signals_catch[] = { SIGINT, SIGQUIT, SIGTERM, SIGHUP, SIGCHLD, SIGUSR1, SIGUSR2 }; /** * Initialize the signal handlers, catch * those signals we are interested in and sets SIGPIPE to be ignored. @@ -265,6 +269,8 @@ Signals_Init(void) #ifdef HAVE_SIGACTION struct sigaction saction; #endif + if (signalpipe[0] > 0 || signalpipe[1] > 0) + return true; if (pipe(signalpipe)) return false; @@ -323,11 +329,12 @@ Signals_Exit(void) sigaction(SIGPIPE, &saction, NULL); #else for (i=0; i < C_ARRAY_SIZE(signals_catch) ; i++) - sigaction(signals_catch[i], &saction, NULL); + signal(signals_catch[i], SIG_DFL); signal(SIGPIPE, SIG_DFL); #endif close(signalpipe[1]); close(signalpipe[0]); + signalpipe[0] = signalpipe[1] = 0; } /* -eof- */