signals.c (xinetd-2.3.15) | : | signals.c (xinetd-2.3.15.4.tar.xz) | ||
---|---|---|---|---|
/* | /* | |||
* (c) Copyright 1992 by Panagiotis Tsirigotis | * (c) Copyright 1992 by Panagiotis Tsirigotis | |||
* (c) Sections Copyright 1998-2001 by Rob Braun | * (c) Sections Copyright 1998-2001 by Rob Braun | |||
* All rights reserved. The file named COPYRIGHT specifies the terms | * All rights reserved. The file named COPYRIGHT specifies the terms | |||
* and conditions for redistribution. | * and conditions for redistribution. | |||
*/ | */ | |||
#include "config.h" | #include "config.h" | |||
#if defined(HAVE_STRSIGNAL) | ||||
#define _GNU_SOURCE | #define _GNU_SOURCE | |||
#endif | ||||
#include <sys/types.h> | #include <sys/types.h> | |||
#include <sys/time.h> | #include <sys/time.h> | |||
#include <signal.h> | #include <signal.h> | |||
#include <syslog.h> | #include <syslog.h> | |||
#include <errno.h> | #include <errno.h> | |||
#include <string.h> | #include <string.h> | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <time.h> | #include <time.h> | |||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | |||
skipping to change at line 184 | skipping to change at line 182 | |||
sig_handler = my_handler ; | sig_handler = my_handler ; | |||
break ; | break ; | |||
case SIGTTIN: | case SIGTTIN: | |||
case SIGTTOU: | case SIGTTOU: | |||
case SIGTSTP: | case SIGTSTP: | |||
if ( debug.on ) | if ( debug.on ) | |||
return( OK ) ; | return( OK ) ; | |||
/* FALL THROUGH */ | /* FALL THROUGH */ | |||
case SIGCONT: | ||||
/* FALL THROUGH */ | ||||
/* | /* | |||
* We may receive a SIGPIPE when handling an internal stream | * We may receive a SIGPIPE when handling an internal stream | |||
* service and the other end closes the connection. | * service and the other end closes the connection. | |||
* We only care about internal services that don't require forking. | * We only care about internal services that don't require forking. | |||
*/ | */ | |||
case SIGPIPE: | case SIGPIPE: | |||
sig_handler = SIG_IGN ; | sig_handler = SIG_IGN ; | |||
sigaddset( &reset_sigs, sig ) ; | sigaddset( &reset_sigs, sig ) ; | |||
break ; | break ; | |||
skipping to change at line 333 | skipping to change at line 333 | |||
{ | { | |||
interval_start = current_time ; | interval_start = current_time ; | |||
interval_signal_count = 1 ; | interval_signal_count = 1 ; | |||
} | } | |||
} | } | |||
char *sig_name( int sig ) | char *sig_name( int sig ) | |||
{ | { | |||
static char signame_buf[ 30 ] ; | static char signame_buf[ 30 ] ; | |||
#if defined(HAVE_STRSIGNAL) | ||||
/* Use strsignal and remove the old sys_siglist stuff */ | /* Use strsignal and remove the old sys_siglist stuff */ | |||
if ( sig < NSIG ) | if ( sig < NSIG ) | |||
return( strx_sprint( signame_buf, sizeof( signame_buf ) - 1, | return( strx_sprint( signame_buf, sizeof( signame_buf ) - 1, | |||
"%d (%s)", sig, strsignal(sig) ) ) ; | "%d (%s)", sig, strsignal(sig) ) ) ; | |||
#else | ||||
#if defined(HAVE_SYS_SIGLIST) | ||||
if ( sig < NSIG ) | ||||
return( strx_sprint( signame_buf, sizeof( signame_buf ) - 1, | ||||
"%d (%s)", sig, sys_siglist[sig] ) ) ; | ||||
#endif | ||||
#endif | ||||
return( strx_sprint( signame_buf, sizeof( signame_buf ) - 1, "%d", sig ) ) ; | return( strx_sprint( signame_buf, sizeof( signame_buf ) - 1, "%d", sig ) ) ; | |||
} | } | |||
/* | /* | |||
* For SIGSEGV and SIGBUS we invoke the bad_signal() function | * For SIGSEGV and SIGBUS we invoke the bad_signal() function | |||
* | * | |||
* For other signals, we just log the fact that they occured. | * For other signals, we just log the fact that they occured. | |||
* SIGINT is a special case since in debug.on mode, it will | * SIGINT is a special case since in debug.on mode, it will | |||
* cause termination. | * cause termination. | |||
*/ | */ | |||
skipping to change at line 385 | skipping to change at line 377 | |||
{ | { | |||
/* Generate a core dump */ | /* Generate a core dump */ | |||
signal(SIGABRT, SIG_DFL); | signal(SIGABRT, SIG_DFL); | |||
abort(); | abort(); | |||
} | } | |||
else | else | |||
bad_signal() ; | bad_signal() ; | |||
break ; | break ; | |||
default: | default: | |||
msg( LOG_NOTICE, func, "Unexpected signal %s", sig_name( sig ) ) ; | /* This will cause a dead lock if the signal happens when the | |||
* daemon is writing / logging something. The message is not | ||||
* important, so comment it out. | ||||
*/ | ||||
// msg( LOG_NOTICE, func, "Unexpected signal %s", sig_name( sig ) ) ; | ||||
if ( debug.on && sig == SIGINT ) | if ( debug.on && sig == SIGINT ) | |||
exit( 1 ) ; | exit( 1 ) ; | |||
} | } | |||
} | } | |||
/* | /* | |||
* The job of this function is to write the signal received to the | * The job of this function is to write the signal received to the | |||
* pipe of pending signals, which is in the main select loop. | * pipe of pending signals, which is in the main select loop. | |||
*/ | */ | |||
static void my_handler( int sig ) | static void my_handler( int sig ) | |||
End of changes. 6 change blocks. | ||||
11 lines changed or deleted | 7 lines changed or added |