[comp.unix.xenix.sco] Catching Signals in 'C'

ramsey@NCoast.ORG (Cedric Ramsey) (09/28/90)

Hello peoplekind. I have a question about the behavior of the
signal function. Firstly, I want to trap the control-c, break,
and other interrupt keys the user may use to stop a program.
I did this by ;

main()
{
  signal (SIGINT, (*handler1) ());
  signal (SIGQUIT, (*handler2) ());
  ... 
}


But, when I type a control-c the program handles the signal as
expected; however, when I type the control-c a second time the program 
doesn't catch it and simply exits. 

I don't know what went wrong. Does anybody outthere have any
thoughts or conjectures ? Any input is needed and desired.

Thanks,

Cedric A. Ramsey
Mail: ramsey@ncoast.ORG

jay@gdx.UUCP (Jay A. Snyder) (09/30/90)

Try:

 Try:

#include <stdio.h>
#include <signal.h>

handler()
{
   ... handler body ....
   signal(SIGINT,handler);
}

main()
{
  signal(SIGINT,handler);
  .....
  .....
}

-- 
==============================================================================
Jay A. Snyder 					 "Let Me Up!  I've had enough"
wa3wbu!gdx!jay@uunet.uu.net
uunet!wa3wbu!gdx!jay