From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Signal Date: Sat, 4 Jan 1997 18:18:49 +0000 Organization: None Lines: 43 Distribution: world Message-ID: References: <1 DOT 5 DOT 4 DOT 16 DOT 19970104111119 DOT 38af165a AT freenet DOT hut DOT fi> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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'. */