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