Bug in isatty (BSD4.2)
hamilton at uiucuxc.Uiuc.ARPA
hamilton at uiucuxc.Uiuc.ARPA
Wed Jul 3 19:17:00 AEST 1985
regarding the bug in isatty(): this problem has been around as long as
isatty() (since V7 at least). my solution:
/*
* isatty - determine whether a file is a tty
*
* isatty (file)
* int file;
*
* returns 1 if file descriptor 'file' refers to a tty, 0 otherwise.
* differs from the standard version in preserving the value
* of "errno" across a potentially erroneous "gtty()".
*
* last modification: 7 aug 82, j w hamilton
*
*/
#include <sgtty.h>
extern int errno;
isatty (file)
int file;
{
register int olderrno = errno;
struct sgttyb ttyb;
if (gtty (file, &ttyb) < 0) {
errno = olderrno;
return (0);
}
return (1);
}
wayne ({decvax,ucbvax}!pur-ee!uiucdcs!uiucuxc!)hamilton
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list