Bug in isatty (all systems!)

Peter da Silva peter at graffiti.UUCP
Mon Sep 2 23:32:31 AEST 1985


> > No, that sentence should read:
> > 	In other words, don't check errno after calling a library routine
> > 	unless it returns an error indication *and* the manual says that it
> > 	sets errno to something meaningful.

errno is an indication of how the last system call failed. In most cases
in section 3 this is also an indication of how the function itself failed.
isatty, fopen(..., "r"), and a few other functions (not available in my
short-term memory) do something other than return a failure when a system call
fails. In fact that's how isatty generally works: it tries to do an lseek
on the file descriptor and returns true if it fails (no flames if it does
some other system call, please...). Fopen(..., "w") does an open(2) then a
creat(2) (except maybe in SV) if the open fails.

> If you're a defender of the cult of UNIX and its teachings, the latter
> is a reasonable statement.  If you want clear and unambiguous documentation
> (which fits my definition of a printed "standard") the former is better.

Surprise! I agree that it wouldn't be hard to clear errno on non-fatal
syscall failures in section (3). There are probably people out there,
however, whose code depends on errno being sacred to all but system calls.

That last statement should read: "If you're trying to use the system as
documented, the latter is a reasonable statement. If you're pointing out
a possible error to be fixed in the next release, the former is better."

>From context it's hard to tell whether your original posting was a complaint
or a request for help, and the writer of ">>" above obviously assumed it
was the latter. Flames about "the cult of UNIX" are not informative.



More information about the Comp.bugs.4bsd.ucb-fixes mailing list