home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / c / 2543 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  3.0 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!jit081.enet.dec.com!diamond
  2. From: diamond@jit081.enet.dec.com (01-Sep-1992 1245)
  3. Newsgroups: comp.std.c
  4. Subject: Re: ANSI description for signal handling
  5. Message-ID: <9209010345.AA20605@enet-gw.pa.dec.com>
  6. Date: 1 Sep 92 03:45:58 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 48
  9.  
  10. In article <9208311827.AA10025@ucbvax.Berkeley.EDU> JENNIFER@TOROLAB6.VNET.IBM.COM ("Jennifer Hamilton") writes:
  11. >( ... also posted to comp.lang.c)
  12.  
  13. In order to do that, you should edit the "Newsgroups:" line in the header
  14. to say "Newsgroups: comp.std.c,comp.lang.c" instead of posting two
  15. separate articles.
  16.  
  17. >In the ANSI standard under the description of the signal function,
  18. >(section 4.7.1.1) it states the following:
  19. >   "The function func may terminate by executing a return statement or
  20. >   by calling the abort, exit, or longjmp functions.  If func executes a
  21. >   return statement and the value of sig was SIGFPE or any other
  22. >   implementation-defined value corresponding to a computational
  23. >   exception, the behaviour is undefined.  Otherwise, the program will
  24. >   resume execution at the point it was interrupted.  If the signal
  25. >   occurs other than as the result of calling the abort or raise
  26. >   function, the behaviour is undefined if the signal handler calls any
  27. >   function in the standard library other than the signal function
  28. >   itself ..."
  29. >The last sentence implies that you can't call any library functions
  30. >(such as longjmp, abort or exit) from within the signal handler unless
  31. >the signal was explicitly raised through raise or abort.
  32.  
  33. That is correct.  (However, even when the standard explicitly leaves the
  34. behavior undefined, an implementation is still allowed to define an
  35. extension if it wishes, and a non-strictly conforming program is allowed
  36. to take advantage of the extension, though it won't be portable.)
  37.  
  38. >But the first three sentences imply that you can.
  39.  
  40. Well, yes and no.  It does seem worded to raise false hopes before quashing
  41. them.  However, it doesn't exactly say that func may call abort, exit, or
  42. longjmp under all circumstances.  The only "standard" circumstance under
  43. which a signal may be received is due to calling abort or raise, and under
  44. this circumstance, there are four defined methods of exiting.  If a signal
  45. is received due to implementation extensions, then the standard says that
  46. the implementation still has to allow an ordinary return statement, but
  47. doesn't have to allow other means of exit from the handler.
  48.  
  49. Now, one might wonder if SIGPFE, SIGILL, SIGINT, SIGSEGV, or SIGTERM might
  50. also be "standard" circumstances for signals to be received.  Well, the
  51. standard says "An implementation need not generate any of these signals,
  52. except as a result of explicit calls to the raise function."  So even though
  53. these macros exist, they do not have "standard" defined meanings.
  54. --
  55. Norman Diamond       diamond@jit081.enet.dec.com
  56. If this were the company's opinion, I wouldn't be allowed to post it.
  57. "Yeah -- bad wiring.  That was probably it.  Very bad."
  58.