- New signal handler.
This commit is contained in:
parent
1df4081e50
commit
43a4bc5b8b
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: irc-oper.c,v 1.13 2002/12/12 12:33:14 alex Exp $";
|
static char UNUSED id[] = "$Id: irc-oper.c,v 1.14 2002/12/19 04:30:00 alex Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -90,8 +90,8 @@ IRC_DIE( CLIENT *Client, REQUEST *Req )
|
||||||
|
|
||||||
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
|
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
|
||||||
|
|
||||||
Log( LOG_NOTICE|LOG_snotice, "Got DIE command from \"%s\", going down!", Client_Mask( Client ));
|
Log( LOG_NOTICE|LOG_snotice, "Got DIE command from \"%s\", shutdown triggered!", Client_Mask( Client ));
|
||||||
NGIRCd_Quit = TRUE;
|
NGIRCd_SignalQuit = TRUE;
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
} /* IRC_DIE */
|
} /* IRC_DIE */
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req )
|
||||||
|
|
||||||
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
|
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
|
||||||
|
|
||||||
Log( LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\", re-reading configuration ...", Client_Mask( Client ));
|
Log( LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\", reload of configuration triggered.", Client_Mask( Client ));
|
||||||
NGIRCd_Rehash( );
|
NGIRCd_SignalRehash = TRUE;
|
||||||
|
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
} /* IRC_REHASH */
|
} /* IRC_REHASH */
|
||||||
|
@ -125,8 +125,8 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
|
||||||
|
|
||||||
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
|
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
|
||||||
|
|
||||||
Log( LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\", going down!", Client_Mask( Client ));
|
Log( LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\", shutdown triggered!", Client_Mask( Client ));
|
||||||
NGIRCd_Restart = TRUE;
|
NGIRCd_SignalRestart = TRUE;
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
} /* IRC_RESTART */
|
} /* IRC_RESTART */
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: log.c,v 1.41 2002/12/12 12:24:18 alex Exp $";
|
static char UNUSED id[] = "$Id: log.c,v 1.42 2002/12/19 04:30:00 alex Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -119,7 +119,7 @@ GLOBAL VOID
|
||||||
Log_Exit( VOID )
|
Log_Exit( VOID )
|
||||||
{
|
{
|
||||||
/* Good Bye! */
|
/* Good Bye! */
|
||||||
if( NGIRCd_Restart ) Log( LOG_NOTICE, "%s done (restarting).", PACKAGE );
|
if( NGIRCd_SignalRestart ) Log( LOG_NOTICE, "%s done (restarting).", PACKAGE );
|
||||||
else Log( LOG_NOTICE, "%s done.", PACKAGE );
|
else Log( LOG_NOTICE, "%s done.", PACKAGE );
|
||||||
|
|
||||||
/* Error-File (stderr) loeschen */
|
/* Error-File (stderr) loeschen */
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: ngircd.c,v 1.64 2002/12/12 11:31:21 alex Exp $";
|
static char UNUSED id[] = "$Id: ngircd.c,v 1.65 2002/12/19 04:29:59 alex Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -65,10 +65,8 @@ main( int argc, const char *argv[] )
|
||||||
|
|
||||||
umask( 0077 );
|
umask( 0077 );
|
||||||
|
|
||||||
NGIRCd_Restart = FALSE;
|
NGIRCd_SignalQuit = NGIRCd_SignalRestart = NGIRCd_SignalRehash = FALSE;
|
||||||
NGIRCd_Quit = FALSE;
|
NGIRCd_NoDaemon = NGIRCd_Passive = FALSE;
|
||||||
NGIRCd_NoDaemon = FALSE;
|
|
||||||
NGIRCd_Passive = FALSE;
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
NGIRCd_Debug = FALSE;
|
NGIRCd_Debug = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -220,7 +218,7 @@ main( int argc, const char *argv[] )
|
||||||
exit( Conf_Test( ));
|
exit( Conf_Test( ));
|
||||||
}
|
}
|
||||||
|
|
||||||
while( ! NGIRCd_Quit )
|
while( ! NGIRCd_SignalQuit )
|
||||||
{
|
{
|
||||||
/* In der Regel wird ein Sub-Prozess ge-fork()'t, der
|
/* In der Regel wird ein Sub-Prozess ge-fork()'t, der
|
||||||
* nicht mehr mit dem Terminal verbunden ist. Mit der
|
* nicht mehr mit dem Terminal verbunden ist. Mit der
|
||||||
|
@ -250,8 +248,9 @@ main( int argc, const char *argv[] )
|
||||||
/* Globale Variablen initialisieren */
|
/* Globale Variablen initialisieren */
|
||||||
NGIRCd_Start = time( NULL );
|
NGIRCd_Start = time( NULL );
|
||||||
(VOID)strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start ));
|
(VOID)strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start ));
|
||||||
NGIRCd_Restart = FALSE;
|
NGIRCd_SignalRehash = FALSE;
|
||||||
NGIRCd_Quit = FALSE;
|
NGIRCd_SignalRestart = FALSE;
|
||||||
|
NGIRCd_SignalQuit = FALSE;
|
||||||
|
|
||||||
/* Module initialisieren */
|
/* Module initialisieren */
|
||||||
Log_Init( );
|
Log_Init( );
|
||||||
|
@ -393,7 +392,10 @@ GLOBAL VOID
|
||||||
NGIRCd_Rehash( VOID )
|
NGIRCd_Rehash( VOID )
|
||||||
{
|
{
|
||||||
CHAR old_name[CLIENT_ID_LEN];
|
CHAR old_name[CLIENT_ID_LEN];
|
||||||
|
|
||||||
|
Log( LOG_NOTICE|LOG_snotice, "Re-reading configuration NOW!" );
|
||||||
|
NGIRCd_SignalRehash = FALSE;
|
||||||
|
|
||||||
/* Alle Listen-Sockets schliessen */
|
/* Alle Listen-Sockets schliessen */
|
||||||
Conn_ExitListeners( );
|
Conn_ExitListeners( );
|
||||||
|
|
||||||
|
@ -417,7 +419,7 @@ NGIRCd_Rehash( VOID )
|
||||||
/* Listen-Sockets neu anlegen: */
|
/* Listen-Sockets neu anlegen: */
|
||||||
Conn_InitListeners( );
|
Conn_InitListeners( );
|
||||||
|
|
||||||
Log( LOG_INFO, "Re-reading of configuration done." );
|
Log( LOG_NOTICE|LOG_snotice, "Re-reading of configuration done." );
|
||||||
} /* NGIRCd_Rehash */
|
} /* NGIRCd_Rehash */
|
||||||
|
|
||||||
|
|
||||||
|
@ -481,23 +483,21 @@ Signal_Handler( INT Signal )
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
/* wir soll(t)en uns wohl beenden ... */
|
/* wir soll(t)en uns wohl beenden ... */
|
||||||
if( Signal == SIGTERM ) Log( LOG_WARNING|LOG_snotice, "Got TERM signal, terminating now ..." );
|
NGIRCd_SignalQuit = TRUE;
|
||||||
else if( Signal == SIGINT ) Log( LOG_WARNING|LOG_snotice, "Got INT signal, terminating now ..." );
|
|
||||||
else if( Signal == SIGQUIT ) Log( LOG_WARNING|LOG_snotice, "Got QUIT signal, terminating now ..." );
|
|
||||||
NGIRCd_Quit = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
/* Konfiguration neu einlesen: */
|
/* Konfiguration neu einlesen: */
|
||||||
Log( LOG_WARNING|LOG_snotice, "Got HUP signal, re-reading configuration ..." );
|
NGIRCd_SignalRehash = TRUE;
|
||||||
NGIRCd_Rehash( );
|
|
||||||
break;
|
break;
|
||||||
case SIGCHLD:
|
case SIGCHLD:
|
||||||
/* Child-Prozess wurde beendet. Zombies vermeiden: */
|
/* Child-Prozess wurde beendet. Zombies vermeiden: */
|
||||||
while( waitpid( -1, NULL, WNOHANG ) > 0);
|
while( waitpid( -1, NULL, WNOHANG ) > 0);
|
||||||
break;
|
break;
|
||||||
|
#ifdef DEBUG
|
||||||
default:
|
default:
|
||||||
/* unbekanntes bzw. unbehandeltes Signal */
|
/* unbekanntes bzw. unbehandeltes Signal */
|
||||||
Log( LOG_NOTICE, "Got signal %d! Ignored.", Signal );
|
Log( LOG_DEBUG, "Got signal %d! Ignored.", Signal );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} /* Signal_Handler */
|
} /* Signal_Handler */
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Please read the file COPYING, README and AUTHORS for more information.
|
* Please read the file COPYING, README and AUTHORS for more information.
|
||||||
*
|
*
|
||||||
* $Id: ngircd.h,v 1.17 2002/12/12 11:30:23 alex Exp $
|
* $Id: ngircd.h,v 1.18 2002/12/19 04:30:00 alex Exp $
|
||||||
*
|
*
|
||||||
* Prototypes of the "main module".
|
* Prototypes of the "main module".
|
||||||
*/
|
*/
|
||||||
|
@ -37,8 +37,9 @@ GLOBAL BOOLEAN NGIRCd_NoDaemon; /* nicht im Hintergrund laufen */
|
||||||
|
|
||||||
GLOBAL BOOLEAN NGIRCd_Passive; /* nicht zu anderen Servern connecten */
|
GLOBAL BOOLEAN NGIRCd_Passive; /* nicht zu anderen Servern connecten */
|
||||||
|
|
||||||
GLOBAL BOOLEAN NGIRCd_Quit; /* TRUE: ngIRCd beenden */
|
GLOBAL BOOLEAN NGIRCd_SignalQuit; /* TRUE: quit server*/
|
||||||
GLOBAL BOOLEAN NGIRCd_Restart; /* TRUE: neu starten */
|
GLOBAL BOOLEAN NGIRCd_SignalRestart; /* TRUE: restart server */
|
||||||
|
GLOBAL BOOLEAN NGIRCd_SignalRehash; /* TRUE: reload configuration */
|
||||||
|
|
||||||
GLOBAL CHAR NGIRCd_DebugLevel[2]; /* Debug-Level fuer IRC_VERSION() */
|
GLOBAL CHAR NGIRCd_DebugLevel[2]; /* Debug-Level fuer IRC_VERSION() */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue