Bug in isatty (all systems!)

Darryl Baker dbaker at cuuxb.UUCP
Thu Jul 18 20:29:38 AEST 1985


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.



More information about the Comp.unix.wizards mailing list