Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucla-cs.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!harpo!whuxlm!whuxl!houxm!ihnp4!qantel!hplabs!sdcrdcf!trwrb!trwrba!cepu!ucla-cs!scw From: scw@ucla-cs.UUCP Newsgroups: net.bugs.4bsd,net.unix-wizards,net.bugs.usg Subject: Re: Bug in isatty (all systems!) Message-ID: <6367@ucla-cs.ARPA> Date: Fri, 19-Jul-85 12:10:33 EDT Article-I.D.: ucla-cs.6367 Posted: Fri Jul 19 12:10:33 1985 Date-Received: Thu, 25-Jul-85 02:47:35 EDT References: <726@mcvax.UUCP> <965@sdcsvax.UUCP> <243@cuuxb.UUCP> Reply-To: scw@ucla-cs.UUCP (Stephen C. Woods) Organization: UCLA Computer Science Department Lines: 43 Xref: linus net.bugs.4bsd:1312 net.unix-wizards:11163 net.bugs.usg:241 In article <243@cuuxb.UUCP> dbaker@cuuxb.UUCP (Darryl Baker) writes: >In article <965@sdcsvax.UUCP> jww@sdcsvax.UUCP (Joel West) writes: >>> The following short C program >>> >>> main(){ >>> extern int errno; >>> >>> errno = 0; >>> putchar('\n'); >>> if(errno > 0) >>> perror("perror"); >>> } >>> >>> gives unexpected results. > .... > Stuff deleted to save space > and keep people interested. > .... >>The other 'gotcha' (same systems) is mktemp, which attempts >>to build a unique file name. errno is always 2 (file not >>found) after successfully calling mktemp on these 3 systems. > >Now I am not going to go into a long explanation of poor coding, but aren't >you supposed to check return values for errors. Lots of section 3 routines >call things from section 2 that set errno. Also isn't also true that the >intro to section 2 states that errno is not cleared on successful calls. The expected value of errno after a mktemp() is 2. mktemp() keeps playing with stat() (I think) and munging the name that it's trying until it fails to find the file, hence this name is unique. The problem is that mktemp() really should clear errno after the last attempt, or that errno == 2 should be a feature (in the BUGS section of mktemp(III)). In fact (on second consideration) you should assume that an errno != 2 means that mktemp() has failed (you didn't allow enough XXXXXX's to generate a unique name). As an aside, has anyone noticed that DEC and [name deleted] have removed the BUGS entries from the man pages? I guess that they're afraid that non UN*X people will think that BUGS means buggy programs, not unavoidable/historical artifacts. Gould however has done the correct thing, They renamed it 'Special Considerations' (rather well named neh?).