Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!julius.cs.uiuc.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!travis!brad From: brad@SSD.CSD.HARRIS.COM (Brad Appleton) Newsgroups: comp.lang.c Subject: Re: Catching Signals in 'C' Summary: Subtlety between BSD and AT&T signals Message-ID: <1103@travis.csd.harris.com> Date: 28 Sep 90 20:31:56 GMT References: <2901@idunno.Princeton.EDU> <2905@idunno.Princeton.EDU> <2910@idunno.Princeton.EDU> Sender: news@travis.csd.harris.com Organization: Harris Computers Systems Division, Fort Lauderdale,FL Lines: 47 There is a difference between AT&T and BSD signal calls (that has already been hinted at) that is important to know in this situation: When you set-up a signal handler in the AT&T universe, your handler is only called the very next time that signal is caught and subsequent calls refer back to the default handler unless you reset your handler in the handler-code. When you set up a signal handler in the BSD universe, your handler is called for all subsequent trappings of that signal unless you specifically reset the handler to be something else in the handler-code. The following code fragment might be used to set up a minimal Control-C handler that would be portable accross Unixes (assuming that "att_universe" is #defined for an AT&T system and "ucb_universe" is #defined for a BSD system): #include #include void ctrl_c_handler() { printf( "\n+++ in ctrl_c_handler() +++\n" ); #ifdef att_universe /* need to reset this handler so we can trap the signal again */ if ( signal( SIGINT, ctrl_c_handler ) < 0 ) perror( "unable to set-up SIGINT handler" ); #endif } main() { if ( signal( SIGINT, ctrl_c_handler ) < 0 ) perror( "unable to set-up SIGINT handler" ); printf( "about to loop forever\n\n" ); while (1); } Anybody know about DOS and/or VMS??? ______________________ "And miles to go before I sleep." ______________________ Brad Appleton brad@travis.ssd.csd.harris.com Harris Computer Systems ...!uunet!hcx1!brad Fort Lauderdale, FL USA ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~