bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: isatty() and errno


From: Eric Blake
Subject: Re: isatty() and errno
Date: Tue, 08 Nov 2011 10:09:40 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.4 Thunderbird/3.1.15

On 11/08/2011 10:07 AM, Paul Eggert wrote:
On 11/08/11 03:33, Bruno Haible wrote:

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

Amusingly enough, this *is* documented in the GNU/Linux man page
<http://www.kernel.org/doc/man-pages/online/pages/man3/isatty.3.html>:

        isatty() returns 1 if fd is an open file descriptor referring to a 
terminal;
        otherwise 0 is returned, and errno is set to indicate the error.

So in this case we have dueling documentation.

If I were writing the code I would just leave gnulib alone, as Bruno suggests,
but I find it hard to argue against a more activist approach
in which gnulib supports the documented GNU/Linux behavior.

Sounds like an isatty-gnu module might be in order, then, which guarantees errno behavior. Those who code to POSIX are aware that errno is not guaranteed, but those who code to glibc don't have to be surprised when porting elsewhere, by importing the new module.

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]