Bug in isatty (all systems!)

scw at ucla-cs.UUCP scw at ucla-cs.UUCP
Sat Jul 20 02:10:33 AEST 1985


In article <243 at cuuxb.UUCP> dbaker at cuuxb.UUCP (Darryl Baker) writes:
>In article <965 at sdcsvax.UUCP> jww at 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?).



More information about the Comp.bugs.4bsd.ucb-fixes mailing list