Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!sgi!shinobu!odin!wanda!bowen From: bowen@wanda.SGI.COM (Jerre Bowen) Newsgroups: comp.sys.sgi Subject: Re: exit signal Message-ID: <1990Dec21.012822.502@odin.corp.sgi.com> Date: 21 Dec 90 01:28:22 GMT References: <13238@milton.u.washington.edu> <9012160645.AA10200@karron.med.nyu.edu> <1990Dec18.153942.15916@odin.corp.sgi.com> Sender: news@odin.corp.sgi.com (Net News) Reply-To: bowen@wanda.SGI.COM (Jerre Bowen) Organization: Silicon Graphics Inc. Lines: 45 In article <13238@milton.u.washington.edu>, merritt@milton.u.washington.edu (Ethan Merritt) writes: > In article <1990Dec18.153942.15916@odin.corp.sgi.com> jmb@patton.wpd.sgi.com (Jim Barton) writes: > >In article <9012160645.AA10200@karron.med.nyu.edu>, Dan > >Karron@UCBVAX.BERKELEY.EDU writes: > > > >> How can I set a signal handler for a software exit() call ? I am > >> looking to catch programs that exit via an exit(value) call, or fall > >> off the end of the main procedure. I do not have control of the user code. > > > >Your description is a little unclear of what you want - I don't know > >what you mean by not having control of the user code. Guessing, the > >easiest way to do this is to use dbx. Ask dbx to stop on a call to exit, > >or even trap the exit system call. dbx will also catch any signals > >posted to the program, so you can always catch the program when it is > >going south. > > I'm not entirely sure what Karron wants in his original posting, but > this reminds me of something which caused me much grief when I started porting > code to IRIX. Nowhere that I can find in the various libraries is an > equivalent to the ANSI C atexit() routine, which allows you to establish > a line of exit handlers which get to clean up before the program exits, no > matter where that exit is triggered from. As Karron mentions, SIGTERM looks > like it might be of some help, but in fact it isn't (too many exit condidions > do not set SIGTERM). > > Any chance of getting atexit() in the next release? > > Ethan A Merritt > ------------------------------------------------------------------------------- > Dept of Biological Structure H510 Health Sciences > University of Washington SM-20 (206)543-8865 > Seattle, WA 98195 merritt@u.washington.edu > ------------------------------------------------------------------------------- atexit() is available now as a separate product, released (I believe) a month or so ago. It is a routine in the ANSI libc; the package also includes an ANSI-compliant compiler. Check it out. Jerre Bowen (bowen@sgi.com)