Mail Archives: djgpp/1997/01/05/03:40:14
Andreas Vernersson writes:
>I've programmed a timer-interrupt (int 0x1c) and it works fine, but
>if i terminate my program with Ctrl-C when the timer is installed
>the computer hung. I think this is caused because i dont't reinstall
>the old interrupt and my timer-interrupt is still there when the program
>tries to exit. So, how do i change the signal caused by Ctrl-C to
>restore the real timer interrupt before exiting. Hm.. And hum..
>how do i make the usual "core dump" appear in the new signal before
>exiting?
I'm not sure off the top of my head which signal it is that ctrl+C
generates, but in my Allegro startup code I install emergency shutdown
handlers for a range of signals, with the code:
signal(SIGABRT, signal_handler);
signal(SIGFPE, signal_handler);
signal(SIGILL, signal_handler);
signal(SIGSEGV, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
signal(SIGKILL, signal_handler);
signal(SIGQUIT, signal_handler);
Within the signal handler itself, you can use raise() to chain to the
original handler, in order to get the usual register dump information.
My code is:
static void signal_handler(int num)
{
static char msg[] = "Shutting down Allegro\r\n";
allegro_exit();
_write(STDERR_FILENO, msg, sizeof(msg)-1);
signal(num, SIG_DFL);
raise(num);
}
/*
* Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
* Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
*/
- Raw text -