This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/22145] ttyname() gives up too early in the face of namespaces


https://sourceware.org/bugzilla/show_bug.cgi?id=22145

--- Comment #19 from Christian Brauner <christian.brauner at mailbox dot org> ---
(In reply to Luke Shumaker from comment #18)
> In cleaning up my patchset, I went to update the manual, since I
> figured ENODEV should be mentioned as a possible return value there.
> And I'm left with a question:
> 
> Does `errno=ENODEV` really convey any more useful information than
> `errno != EBADF && errno != ENOTTY`?  It has already passed `isatty()`
> (well `tcgetattr()`).
> 
> Prior to Serge & your change, name=NULL/errno=unchanged signaled "the
> file descriptor is valid, and is associated with a terminal, but the
> associated file name could not be determined".  ENODEV is mostly that
> same thing, but "is associated with a PTY", instead of a generic TTY.
> Is that a meaningful distinction to make?

While POSIX does explicitly allow for this case I prefer setting errno to a
meaningful value on error. I don't like conveying information implicitly be it
in the error or success case. That's best left for cocktail parties in the
Oxford common room. :)

> 
> What about using ENODEV for all cases were the file descriptor is
> valid, and is associated with a terminal, but the associated file name
> could not be determined?

This is not the focus of this patch. I'd prefer if this patch fixed the single
issue of making parsing through /dev work correctly.
In general, I'd consider all {p,t}y codepaths to be tricky since it is very
easy to break backwards compatibility without realizing it. Let's not
generalize the use of ENODEV right now.

> 
> AFAICT, the only other cases where this can happen are if `/proc` and
> `/dev` are not mounted/set-up as expected.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]