home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18962 < prev    next >
Encoding:
Text File  |  1992-12-29  |  2.7 KB  |  55 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!spillman!tye
  3. From: tye@spillman.uucp (E. Tye McQueen)
  4. Subject: Re: longjumping out of a signal handler
  5. Message-ID: <1992Dec29.090751.19839@spillman.uucp>
  6. Date: Tue, 29 Dec 1992 09:07:51 GMT
  7. References: <1992Dec09.185512.33137@spillman.uucp> <1992Dec11.120446.28991@cs.utwente.nl> <1992Dec14.223422.39678@spillman.uucp> <1992Dec17.121037.446@thinkage.on.ca>
  8. Organization: Spillman Data Systems
  9. Lines: 44
  10.  
  11. dat@thinkage.on.ca (David Adrien Tanguay) writes:
  12. )ANSI 4.7.1.1
  13. )   If the signal occurs other than as a result of calling the abort or
  14. )   raise function, the behaviour is undefined if the signal handler calls
  15. )   any function in the standard library other than the signal function
  16. )   itself (with a first argument of the signal number corresponding to
  17. )   the signal that caused the invocation of the handler) or refers to
  18. )   any object with static storage duration other than by assigning a
  19. )   value to a static storage durection variable of type volatile
  20. )   sig_atomic_t.
  21. )
  22. )You cannot portably call longjmp from a signal handler (modulo abort/raise).
  23.  
  24. Thanks for all the good input on this.
  25.  
  26. I'd note that "portably" above refers to an ANSI C environment,
  27. obviously.  Especially since most pre-ANSI C implementations don't
  28. even have the raise() function nor sig_atomic_t type.  longjmp()ing
  29. out of a signal handler can be ported across several flavors of
  30. Unix, though such systems usually support more portable techniques.
  31.  
  32. My last (I hope) question is:  If you find yourself working on a system
  33. where system calls or library functions, like read() or fread(), are
  34. "restarted" for you after being interrupted by a caught signal, how do
  35. you cause the system call or library function to fail (exit) so you
  36. can go on to something else?  (I don't believe I have access to such
  37. a system so I can't RTFM.)  I know I can use select() or similar
  38. functions, if available, but in my porting environment that is much
  39. less portable than longjmp()ing out.
  40.  
  41. Well, I do have one more thing I'm curious about.  I assume the
  42. ANSI committee left the behavior of longjmp()ing out of a signal
  43. handler undefined because it was felt that some systems would
  44. find it very hard to support such actions.  Was this mostly for
  45. non-Unix systems or is there some particularly hard task involved
  46. in "fixing" some Unix system(s) to support it?  Or was it more that
  47. the same purposes could be served via the sig_atomic_t stuff with
  48. very little work for existing systems to support it?
  49.  
  50. Thanks again,
  51.  tye@spillman.com                         Tye McQueen, E.
  52. ----------------------------------------------------------
  53.  Nothing is obvious unless you are overlooking something. 
  54. ----------------------------------------------------------
  55.