Bug in isatty (BSD4.2)

Andries Brouwer aeb at mcvax.UUCP
Fri Jun 28 03:36:22 AEST 1985


The following short C program

main(){
	extern int errno;

	errno = 0;
	putchar('\n');
	if(errno > 0)
		perror("perror");
}

gives unexpected results.
E.g.
	a.out | ...
gives the error message "Operation not supported on socket".
The reason is that putchar calls putc calls _flsbuf calls isatty
and isatty contains the code
	if(ioctl(f,TIOCGETP,&ttyb)<0)
		return(0);
Probably it should do errno = 0 before the return(0).

We noticed this bug because the new pic and eqn started to give
strange error messages.



More information about the Comp.unix.wizards mailing list