/****************************************************************************/ /* AH-HOC LOGGING OF SPURIOUS SIGNALS ABSTRACTION */ /****************************************************************************/ #include //-------------------------------------------------------------------------- // // NAME: cleanup_sig // // ACCESS: N/A // // DESCRIPTION: Log unexpected signals and exit the process immediately. // // RETURNS: To that big CPU in the sky ... // // REMARKS: Uses the Unix syslog() facility to indicate a signal // we didn't expect, plus (a hopefully) accurate register // dump (which really depends upon how the code was compiled, // and if EBP is used as a stack frame register or not; the // code works under GCC that uses EBP as a stack frame // register, hopefully, egcs++ uses a similar convention and // any extra C++ stuff doesn't get into the way. // // You have been warned. // // AUTHOR: S. Conner // CREATED: Mar 30, 2003 // LAST MODIFIED: N/A // //-------------------------------------------------------------------------- static void cleanup_sig(int sig) { unsigned long *pdump = (unsigned long *)&sig; syslog(LOG_ALERT,"Unexpected signal %d - register dump *may* be accurate",sig); syslog(LOG_ALERT,"EIP: %08lX",pdump[15]); syslog(LOG_ALERT,"EAX: %08lX",pdump[12]); syslog(LOG_ALERT,"EBX: %08lX",pdump[ 9]); syslog(LOG_ALERT,"ECX: %08lX",pdump[11]); syslog(LOG_ALERT,"EDX: %08lX",pdump[10]); syslog(LOG_ALERT,"ESI: %08lX",pdump[ 6]); syslog(LOG_ALERT,"EDI: %08lX",pdump[ 5]); syslog(LOG_ALERT,"EBP: %08lX",pdump[ 7]); syslog(LOG_ALERT,"ESP: %08lX",pdump[ 8]); _exit(1); } //--------------------------------------------------------------------------- // // NAME: HttpdOpSys::BigSignalJuJu // // Access: public // // DESCRIPTION: Sets a default handler for every signal to log the signal // via the syslog() (to the LOG_LOCAL0 facility). // // RETURNS: 0 if successfully configured the signal action for every // signal, otherwise 1 is returned, and errno is set // appropriately. // // REMARKS: Only added because it was required // // AUTHOR: S. Conner // CREATED: Mar 30, 2003 // LAST MODIFIED: N/A // //--------------------------------------------------------------------------- int HttpdOpSys::BigSignalJuJu() { struct sigaction act; struct sigaction oact; sigemptyset(&act.sa_mask); act.sa_handler = cleanup_sig; act.sa_flags = 0; if ( #ifdef SIGPIPE sigaction(SIGPIPE,&act,&oact) == -1 #endif #ifdef SIGABRT || sigaction(SIGABRT,&act,&oact) == -1 #endif #ifdef SIGALRM || sigaction(SIGALRM,&act,&oact) == -1 #endif #ifdef SIGBUS || sigaction(SIGBUS,&act,&oact) == -1 #endif #ifdef SIGCHLD || sigaction(SIGCHLD,&act,&oact) == -1 #endif #ifdef SIGCONT || sigaction(SIGCONT,&act,&oact) == -1 #endif #ifdef SIGEMT || sigaction(SIGEMT,&act,&oact) == -1 #endif #ifdef SIGFPE || sigaction(SIGFPE,&act,&oact) == -1 #endif #ifdef SIGHUP || sigaction(SIGHUP,&act,&oact) == -1 #endif #ifdef SIGILL || sigaction(SIGILL,&act,&oact) == -1 #endif #ifdef SIGINFO || sigaction(SIGINFO,&act,&oact) == -1 #endif #ifdef SIGINT || sigaction(SIGINT,&act,&oact) == -1 #endif #ifdef SIGIO || sigaction(SIGIO,&act,&oact) == -1 #endif #ifdef SIGIOT || sigaction(SIGIOT,&act,&oact) == -1 #endif #ifdef SIGPOLL || sigaction(SIGPOLL,&act,&oact) == -1 #endif #ifdef SIGPROF || sigaction(SIGPROF,&act,&oact) == -1 #endif #ifdef SIGPWR || sigaction(SIGPWR,&act,&oact) == -1 #endif #ifdef SIGQUIT || sigaction(SIGQUIT,&act,&oact) == -1 #endif #ifdef SIGSEGV || sigaction(SIGSEGV,&act,&oact) == -1 #endif #ifdef SIGSYS || sigaction(SIGSYS,&act,&oact) == -1 #endif #ifdef SIGTERM || sigaction(SIGTERM,&act,&oact) == -1 #endif #ifdef SIGTRAP || sigaction(SIGTRAP,&act,&oact) == -1 #endif #ifdef SIGLOST || sigaction(SIGLOST,&act,&oact) == -1 #endif #ifdef SIGTSTP || sigaction(SIGTSTP,&act,&oact) == -1 #endif #ifdef SIGTTIN || sigaction(SIGTTIN,&act,&oact) == -1 #endif #ifdef SIGTTOU || sigaction(SIGTTOU,&act,&oact) == -1 #endif #ifdef SIGURG || sigaction(SIGURG,&act,&oact) == -1 #endif #ifdef SIGUSR1 || sigaction(SIGUSR1,&act,&oact) == -1 #endif #ifdef SIGUSR2 || sigaction(SIGUSR2,&act,&oact) == -1 #endif #ifdef SIGVTALRM || sigaction(SIGVTALRM,&act,&oact) == -1 #endif #ifdef SIGWINCH || sigaction(SIGWINCH,&act,&oact) == -1 #endif #ifdef SIGXCPU || sigaction(SIGXCPU,&act,&oact) == -1 #endif #ifdef SIGXFSZ || sigaction(SIGXFSZ,&act,&oact) == -1 #endif #ifdef SIGSTKFLT || sigaction(SIGSTKFLT,&act,&oact) == -1 #endif #ifdef SIGTSTP || sigaction(SIGTSTP,&act,&oact) == -1 #endif ) { return(1); } openlog("Seminole",LOG_PID,LOG_LOCAL0); return(0); }