home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sgi / misc / 51 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.2 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ans.net!cmcl2!adm!news
  2. From: HERBER@fnal.fnal.gov (Randolph J. Herber, CD/DCD/SPG, x2966)
  3. Newsgroups: comp.sys.sgi.misc
  4. Subject: RE: tempnam(3S) bug, possibly on all MIPS
  5. Message-ID: <34762@adm.brl.mil>
  6. Date: 20 Dec 92 16:33:59 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 53
  9.  
  10. RTFM!
  11.  
  12. Quoting from `man 2 intro' of my AT&T 3B1 UNIX manual set (and this manual
  13. set dates from a decade ago -- UNIX has not changed in this respect during
  14. this time):
  15.  
  16. Most of these calls have one or more error returns. **An error condition is
  17. indicated by an otherwise impossible returned value.** [Emphasis mine] This
  18. is almost always -1; the individual descriptions specify the details.  An
  19. error number is also made available in the external variable *errno*. [Italics
  20. theirs] *Errno* [italics theirs] **is not cleared** [emphasis mine] on success-
  21. ful calls, so it should be test only after an error has been indicated.
  22.  
  23. You made a mistake.
  24.  
  25. tempnam() in the course of its internal processing may create one or more
  26. error conditions that it recovers from itself.  E.g., it may create a
  27. file name that is already in use.  Detecting this condition, it repeatly
  28. generates more until it finds a name that is not in use.  `tempnam()' does
  29. not clear errno afterwards!
  30.  
  31. Check for an error return from your system call or library call *first*!
  32. *Only* if an error is indicated, should you check errno to determine what
  33. error.
  34.  
  35. Randolph J. Herber, herber@fnalf.fnal.gov, +1 708 840 2966
  36. (Speaking for myself and not for US, US DOE, FNAL nor URA.)
  37. (Product, trade, or service marks herein belong to their respective owners.)
  38.  
  39. +From: "T.C. Zhao" <svec5@menudo.uh.edu>
  40. +Newsgroups: comp.sys.sgi,comp.sys.sgi.bugs,comp.unix.ultrix
  41. +Subject: tempnam(3S) bug, possibly on all MIPS
  42. +Date: 19 Dec 92 04:23:37 GMT
  43.  
  44. +It appears that tempnam(3S) is broken on three MIPS machines I have
  45. +access to:   IRIX 3.3, Ultrix 4.1, UMIPS 4.52:
  46.  
  47. +/* 
  48. + * check to see if tempnam has the errno bug.
  49. + */
  50. +#include <stdio.h>
  51. +#include <stdlib.h>
  52. +#include <unistd.h>
  53. +#include <errno.h>
  54.  
  55. +int main(int argc, char **argv)
  56. +{
  57. +   char *p;
  58. +   errno = 0;
  59. +   p = tempnam(0, 0);
  60. +   if(errno) fprintf(stderr," tempnam is broken\n");
  61. +   return 0;
  62. +}
  63.