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: Mon, 07 Nov 2011 16:52:07 -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/07/2011 04:18 PM, Eric Blake wrote:
Our assumption in ptsname.c is that isatty() will set errno on invalid
fds. But this is not required by POSIX, and indeed not enforced by
Solaris 10; that is, our ptsname.c implementation was copied from glibc,
and was making an assumption only guaranteed by glibc's implementation
choice for isatty(), which ends up leaving errno unchanged when that
code is compiled on Solaris.

But 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? Or should I just patch ptsname.c to
guarantee that errno is set without relying on isatty() to do the job?

Yuck. Making ptsname_r wrap ptsname() makes it possible to avoid the isatty() non-errno on Solaris, but exposes a FreeBSD 8.2 bug that ptsname(-1) doesn't set errno.

Also, glibc ptsname_r(-1, buf, len) sets errno to ENOTTY, even though EBADF seems like it would be the more canonical choice (and given the comments in ptsname.c, that seems like EBADF should be the behavior, since isatty() is supposed to distinguish between open but non-terminals, and altogether bad fds).

--
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]