Eric Blake wrote:
> that means it is likely that other GNU code will assume isatty() 
> sets errno.  Should we provide an isatty() module that guarantees that 
> errno will be set when returning 0?

The fact that isatty() always sets errno in glibc is undocumented:

 -- Function: int isatty (int FILEDES)
     This function returns `1' if FILEDES is a file descriptor
     associated with an open terminal device, and 0 otherwise.

And the POSIX wording is (emphasis is mine):

    The isatty() function shall return 1 if fildes is associated
    with a terminal; otherwise, it shall return 0 and *may* set
    errno to indicate the error.

People should program against standards. So people should get used to
write

    errno = 0;
    if (!isatty (fd))
      {
        if (errno == 0)
          errno = ENOTTY;
      }

even if it looks complicated. That's the way the standard is.

Bruno
-- 
In memoriam The inmates of the Daugavpils Ghetto 
<http://en.wikipedia.org/wiki/Daugavpils_Ghetto>

Reply via email to