🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2343

Question: signal and program termination

#2343
From: deron meranda
Date: Tue, 29 Jan 1991 20:24
35 lines
2397 bytes
I have some questions about the ANSI defined behavior of signals
and program termination.

1) Supposedly, any signal handler can be exited by returning from the
   handler, or calling one of abort(), exit(), or longjmp().  However,
   the use of longjmp() is discouraged because the signal could have
   interrupted a non-atomic operation.  But couldn't the same scenario
   occur by calling exit() within a handler?  Clearly, any cleanup
   functions set up by atexit() would have to be called.  However, if
   some data was left in an undefined state because of the signal,
   then couldn't these exit functions completely fail?

2) I am not quite sure of the connection (or allowable connection)
   between abort() and raise(SIGABRT).  What happens if the handler
   for SIGABRT is set to SIG_IGN and later abort() is called?  Also,
   what happens if a user supplied handler is installed for SIGABRT...
   Since abort() is not permitted to return, what would happen if
   the handler decided to call exit(), longjmp(), or even worse
   abort() again, rather than strictly returning?  Would this defeat
   the "no-return-permitted" characteristic of abort()?

3) I would assume that signal handlers are permitted to raise other
   signals.  Say, if the default action for SIGINT's handler was to
   terminate the program, would it be more appropriate to raise
   SIGABRT or SIGTERM -- or should it just call exit() and suffer the
   same problems mentioned in question 1?

4) A simple one:  supposedly all signal handlers are permitted to
   simply return, _except_ for those signals that indicate a
   computational exception.  Among the ANSI defined signals, which
   ones do indicate a computational exception?

Thanks!

Deron E. Meranda  ( meranda@cis.ohio-state.edu )
Technical Details
Message-ID: <87792@tut.cis.ohio-state.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!tut.cis.ohio-state.edu!iguana.cis.ohio-state.edu!meranda

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!tut.cis.ohio-state.edu!iguana.cis.ohio-state.edu!meranda
From: meranda@iguana.cis.ohio-state.edu (deron meranda)
Newsgroups: comp.std.c
Subject: Question: signal and program termination
Keywords: signal, exit, termination
Message-ID: <87792@tut.cis.ohio-state.edu>
Date: 29 Jan 91 20:24:54 GMT
Sender: news@tut.cis.ohio-state.edu
Reply-To: <meranda@iguana.cis.ohio-state.edu>
Organization: Ohio State University Computer and Information Science
Lines: 35