Bug in isatty (all systems!)

hamilton at uiucuxc.Uiuc.ARPA hamilton at uiucuxc.Uiuc.ARPA
Sun Jul 28 10:25:00 AEST 1985


>  MY 4.2bsd manual says:
>      ... An
>     error number is also made available in the external variable
>     _errno_, which is not cleared on successful calls.  Thus _errno_
>     should be tested only after an error has occurred.
>
>  What does "not cleared on successful calls" mean to you?  To me, it
>means that if I set errno = 0 in the beginning of my program, it will
>stay zero until a system call _fails_, then it will stay non-zero long
>enough for me to do something about it.  Now if a perfectly successful
>operation sets errno and does not bother to clear it, how can I depend
>on errno as an indication that something went _wrong_?
>
>  Remember, TFM does not say anywhere that _successful_ operations set
>errno, which is what, in effect, happens here.  Or should the whole
>world know how fopen() is implemented, in order to decipher errno
>in context?

    RTFM is STILL applicable here...
    "not cleared on successful calls" means exactly what it says:
"successful calls to the functions IN SECTION 2 do not clear errno".
    notice that that quote is from intro(2), while the functions
causing all this ruckus are from section 3, and intro(3) mentions
errno only in the context of math functions.  i don't want to dig
out my V6 manuals, but i'm fairly sure errno used to be exclusively
maintained by the system call interface functions.  library functions
are NOT system calls.  they are "customers" of section 2 and errno just
as your code is.  whether they should be messing with the system call
interface is debatable; do all of YOUR subroutines clear errno upon
successful return?
	wayne ({decvax,ucbvax}!pur-ee!uiucdcs!uiucuxc!)hamilton



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