Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site sdcsvax.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!harpo!decvax!ittvax!dcdwest!sdcsvax!jww
From: jww@sdcsvax.UUCP (Joel West)
Newsgroups: net.bugs.4bsd,net.unix-wizards,net.bugs.usg
Subject: Re: Bug in isatty (all systems!)
Message-ID: <965@sdcsvax.UUCP>
Date: Tue, 9-Jul-85 20:15:32 EDT
Article-I.D.: sdcsvax.965
Posted: Tue Jul  9 20:15:32 1985
Date-Received: Fri, 12-Jul-85 03:27:50 EDT
References: <726@mcvax.UUCP>
Organization: CACI, Inc - Federal, La Jolla
Lines: 26
Xref: watmath net.bugs.4bsd:1599 net.unix-wizards:13782 net.bugs.usg:247

> The following short C program
> 
> main(){
> 	extern int errno;
> 
> 	errno = 0;
> 	putchar('\n');
> 	if(errno > 0)
> 		perror("perror");
> }
> 
> gives unexpected results.
> The reason is that putchar calls putc calls _flsbuf calls isatty
> and isatty contains the code
> 	if(ioctl(f,TIOCGETP,&ttyb)<0)
> 		return(0);

(which sets errno=25: not a typewriter unless stdout is /dev/tty)

I was going to post this one myself.  I found it on BSD 4.2, 
System V/2.0 and UTX-32 (a Gould BSD + V port).  It really
screwed me up bad.

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.