delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/04/01/16:24:30

Message-Id: <199903312046.UAA50148@out4.ibm.net>
From: "Mark E." <snowball3 AT usa DOT net>
To: djgpp-workers AT delorie DOT com
Date: Wed, 31 Mar 1999 15:46:55 -0500
MIME-Version: 1.0
Subject: Bash ctrl-c problem simplified
X-mailer: Pegasus Mail for Win32 (v3.01d)
Reply-To: djgpp-workers AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019