Mail Archives: djgpp-workers/1999/04/01/16:24:30
When I compile and execute this program, I get a traceback instead of
what the documentation below (taken from signal) describes. Does the
special SIGINT behavior only apply when the ctrl-c key is pressed or
should it also apply to kill() generated interrupts?
#include <signal.h>
int main()
{
kill (getpid(), SIGINT);
return 0;
}
Here's the relavant portion of libc.info from the signal function:
The default handling for the rest of the
signals is to print a
traceback (a stack dump which describes the
sequence of function calls
leading to the generation of the signal) and
abort the program by
calling `_exit' (*note _exit::.). As an
exception, the default handler
for the signal `SIGINT' doesn't print the
traceback, and calls `exit'
instead of `_exit', when the INTR key (`Ctrl-C'
by default) is pressed,
so that programs could be shut down safely in
this manner.
What happens in Bash when ctrl-c is pressed is
the SIGINT handler is called to do cleanup, it
then resets the SIGINT handler to the default,
then calls kill(). The default SIGINT handler
then calls the traceback routine. I can
probably fix this in Bash, but does libc's
SIGINT handling need fixing too?
---
Mark Elbrecht, snowball3 AT usa DOT net
http://snowball.digitalspace.net/
- Raw text -