home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12851 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.9 KB  |  53 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!mdisea!mitchell
  3. From: mitchell@mdd.comm.mot.com (Bill Mitchell)
  4. Subject: errno  (was Re: Too many open files)
  5. Message-ID: <1992Aug27.142224.9152@mdd.comm.mot.com>
  6. Sender: news@mdd.comm.mot.com
  7. Bcc:  mitchell
  8. Reply-To: mitchell@mdd.comm.mot.com (Bill Mitchell)
  9. Organization: Motorola, Mobile Data Division - Seattle, WA
  10. References: <28622@vedge.UUCP> <1992Aug27.065803.28247@klaava.Helsinki.FI>
  11. Date: Thu, 27 Aug 1992 14:22:24 GMT
  12. Lines: 39
  13.  
  14. in comp.lang.c, wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) said:
  15.  
  16.  
  17. >michel@vedge.UUCP (Michel Trudeau) writes:
  18. >> [* fopen fails, some compilers set errno, some don't *]
  19. >
  20. >Yes.  There is no guarantee that fopen set errno to anything at all.
  21. >
  22. >--
  23. >Lars.Wirzenius@helsinki.fi
  24.  
  25. That's the bottom line, but a bit terse.  Let me expand a bit, reading
  26. from PJP's book The Standard C Library:
  27.  
  28. Page 50, Using <errno.h> starts out:
  29.  
  30. "The C Standard leaves much unsaid about the errors that can be reported.
  31. It says even less about the values of any error codes [.....] Even different
  32. versions of UNIX define dirrerent sets of error codes.  If you are writing
  33. code for a specific system you may have to learn its peculiar set of error
  34. codes.  List the header <errno.h> if you can. [...]"
  35.  
  36. In section 7.1.14, the standard says, "The value of errno is zero at program
  37. startup, but it is never set to zero by any library function.  The value of
  38. errno may be set to nonzero by a library function call whether or not there
  39. is an error, provided the use of errno is not documented in the description
  40. of the function in this International Standard."
  41.  
  42. Section 7.9.5.3, on the fopen function, does not document the use of errno
  43. by fopen.
  44.  
  45. So, there is no guarantee that fopen set errno to anything at all, but
  46. it is allowed to set errno to any nonzero value whether or not there
  47. was an error.  See implementation-specific documentation for implementation-
  48. specific details.
  49.  
  50. -- 
  51. mitchell@mdd.comm.mot.com (Bill Mitchell)
  52.  
  53.