home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / arch / 11984 < prev    next >
Encoding:
Text File  |  1992-12-29  |  2.1 KB  |  52 lines

  1. Newsgroups: comp.arch
  2. Path: sparky!uunet!gatech!darwin.sura.net!bogus.sura.net!pandora.pix.com!stripes
  3. From: stripes@pix.com (Josh Osborne)
  4. Subject: Re: <None> (Should be Open Systems, bloody NEWS system...)
  5. Message-ID: <C011xo.KDu@pix.com>
  6. Sender: news@pix.com (The News Subsystem)
  7. Nntp-Posting-Host: pandora.pix.com
  8. Organization: Pix Technologies -- The company with no adult supervision
  9. References: <1992Dec23.212321.26522@ryn.mro4.dec.com> <id.SQ3W.IB6@ferranti.com> <1992Dec29.012215.10632@ryn.mro4.dec.com>
  10. Date: Tue, 29 Dec 1992 15:34:34 GMT
  11. Lines: 39
  12.  
  13. In article <1992Dec29.012215.10632@ryn.mro4.dec.com> Peter.Mayne@cao.mts.dec.com writes:
  14. [...]
  15. >** I believe that you can also run into problems if you have
  16. >** a signal handler that gets invoked, and resets errno in the period
  17. >** between your successful system call and your test for success. It's
  18. [...]
  19. >Fixing this kind of problem would involve changing the model of "returning
  20. >an error flag and a static errno". You could:
  21. >
  22. >- return an error status rather than an error flag
  23. >- signal on errors
  24. >- call a "callback" routine on errors
  25. >- fill in a program-provided "status block" (non-static "errno" equivalent)
  26. >
  27. >Any one of these would probably be considered incompatible by a large number
  28. >of UNIX style programmers (including DOS programmers and a lot of VMS
  29. >programmers).
  30.  
  31. Yes, this is a big problem with the way Unix does error reporting.  However
  32. you can kludge around it like this:
  33.  
  34. sighandler(...)
  35. {
  36.     int old_errno = errno;
  37.     /* do stuff */
  38.     errno = old_errno;
  39. }
  40.  
  41. Note: you need to do this even if you exit()/abort() after any syscall failure.
  42. I beleve that syscalls are allowed to alter errno even on a succesful return.
  43.  
  44. (also this doesn't magicly make all of libc rentrent, but it does mean that
  45. if someone has a rentrent libc you can use it and not stomp errno...)
  46. -- 
  47.            stripes@pix.com              "Security for Unix is like
  48.       Josh_Osborne@Real_World,The          Multitasking for MS-DOS"
  49.       "The dyslexic porgramer"                  - Kevin Lockwood
  50. We all agree on the necessity of compromise.  We just can't agree on
  51. when it's necessary to compromise.       - Larry Wall
  52.