Subject: bug#26371: [PATCH 0/1] tty: do not provide conflicting information

From: Christian Brauner <[email-masked]>
Date: Wed, 5 Apr 2017 22:17:18 +0200

Hi Paul,

Thanks for the quick response. :)

On Wed, Apr 05, 2017 at 11:40:15AM -0700, Paul Eggert wrote:
> Thanks for the bug report. The situation you describe seems to be a platform
> that does not conform to POSIX, since POSIX doesn't allow for isatty to
> succeed but ttyname to fail. So I expect you'll run into problems other than

Oh, where can that information be gathered from? I looked up isatty() and
ttyname{_r}() in:

The Open Group Base Specifications Issue 7
IEEE Std 1003.1-2008, 2016 Edition
Copyright © 2001-2016 The IEEE and The Open Group

but couldn't find any such requirement that forces an alignment between isatty()
and ttyname{_r}().

> with the tty program, as other software will make the same assumptions that
> tty is making.
> 
> That being said, tty could do a better job about the situation. I installed
> the attached somewhat-more-ambitious patch, so that tty will do
> more-extensive checking of the results of isatty and/or ttyname (and so that
> it never needs to call both functions and worry about whether their results
> are consistent :-). Please give it a try on your platform.

Form a purely technical perspective it just seems to make a lot more sense to
exit with success if the file descriptor actually refers to a terminal. The name
of the device it refers to just seems syntactical sugar. :)

Thanks again!
Christian