Mail Archives: djgpp/1997/01/04/20:09:22
From: | snarfy AT goodnet DOT com
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Signal
|
Date: | 4 Jan 1997 21:46:46 GMT
|
Organization: | GoodNet
|
Lines: | 31
|
Message-ID: | <5amj46$vd6@news.goodnet.com>
|
NNTP-Posting-Host: | goodnet.com
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
>Well, to trap Ctrl-C, just install a signal handler for SIGINT like so:
>
>void my_handler( int sig );
>{
> ...
>}
>
>signal( SIGINT, my_handler );
>
>Your signal handler can then take care of restoring interrupts,
>deallocating DOS memory, etc. As far as getting a traceback printed,
>there was a big discussion a while back about how to do it, but I don't
>remember the details. I'm sure somebody does though. :)
>
All you need to do is call the old handler which will do the core dump.
Example:
void (*old_handler)(int);
old_handler = signal(SIGINT, my_handler);
void my_handler(int signum)
{
... free some stuff, cleanup, etc
old_handler(signum); /* calls the old handler, which does the dump */
}
Josh
snarfy AT goodnet DOT com
- Raw text -