signal handling improvements

This commit is contained in:
Bill Currie 2002-03-13 19:20:57 +00:00
parent 6aa4a690d6
commit 180c517771
2 changed files with 26 additions and 14 deletions

View file

@ -56,7 +56,7 @@ void Sys_Print (FILE *stream, const char *fmt, va_list args);
void Sys_Printf (const char *fmt, ...) __attribute__((format(printf,1,2)));
void Sys_DPrintf (const char *fmt, ...) __attribute__((format(printf,1,2)));
void Sys_Error (const char *error, ...) __attribute__((format(printf,1,2), noreturn));
void Sys_Quit (void);
void Sys_Quit (void) __attribute__((noreturn));;
void Sys_Shutdown (void);
void Sys_RegisterShutdown (void (*func) (void));
double Sys_DoubleTime (void);

View file

@ -207,22 +207,34 @@ aiee (int sig)
static void
TragicDeath (int sig)
{
signal (SIGHUP, aiee);
signal (SIGINT, aiee);
signal (SIGQUIT, aiee);
signal (SIGILL, aiee);
signal (SIGTRAP, aiee);
signal (SIGIOT, aiee);
signal (SIGBUS, aiee);
signal (SIGSEGV, aiee);
signal (SIGTERM, aiee);
printf ("Received signal %d, exiting...\n", sig);
if (!setjmp (aiee_abort))
Sys_Shutdown ();
switch (sig) {
case SIGHUP:
case SIGINT:
case SIGTERM:
signal (SIGHUP, SIG_DFL);
signal (SIGINT, SIG_DFL);
signal (SIGTERM, SIG_DFL);
Sys_Quit ();
default:
signal (SIGQUIT, aiee);
signal (SIGILL, aiee);
signal (SIGTRAP, aiee);
signal (SIGIOT, aiee);
signal (SIGBUS, aiee);
signal (SIGSEGV, aiee);
signal (sig, SIG_DFL);
if (!setjmp (aiee_abort))
Sys_Shutdown ();
signal (SIGQUIT, SIG_DFL);
signal (SIGILL, SIG_DFL);
signal (SIGTRAP, SIG_DFL);
signal (SIGIOT, SIG_DFL);
signal (SIGBUS, SIG_DFL);
signal (SIGSEGV, SIG_DFL);
}
}
void