From: utzoo!decvax!pur-ee!uiucdcs!uicsovax!hamilton Newsgroups: net.bugs.4bsd Title: isatty() - (nf) Article-I.D.: uiucdcs.732 Posted: Mon Sep 20 11:38:40 1982 Received: Tue Sep 21 08:01:45 1982 #N:uicsovax:2200006:000:695 uicsovax!hamilton Sep 17 18:44:00 1982 isatty() uses gtty() to determine whether a file is a tty. it works fine, but when the file is not a tty, the global errno gets set. this can confuse some autodiagnostic functions (eg perror) that get called for non-syscall related errors. i propose the following slightly modified isatty.c: /* @(#)isatty.c 4.1 (Berkeley) 12/21/80 */ /* * Returns 1 iff file is a tty */ #includeextern int errno; isatty (f) { register int save_errno = errno; struct sgttyb ttyb; if (gtty(f, &ttyb) < 0) { errno = save_errno; return(0); } return(1); } wayne hamilton ({ucbvax,harpo}!pur-ee!uiucdcs!uicsovax!hamilton)