]> git.ipfire.org Git - thirdparty/coreutils.git/commit
tty: handle misconfigured namespaces
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 5 Apr 2017 18:34:42 +0000 (11:34 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 5 Apr 2017 18:35:35 +0000 (11:35 -0700)
commit937388c3059d321797ac327452d71494fcebc655
tree2c929cde39f6e104525a4fe84ff6120b3cade08e
parent4c85c757e55c1b75635672624632e3e6c92c5dd1
tty: handle misconfigured namespaces

On some platforms, isatty succeeds but ttyname fails.
POSIX does not seem to allow this, but there it is.
Problem reported by Christian Brauner (Bug#26371).
While we’re at it, check for errors more carefully and return a
new exit status 4 if stdin is closed or a similar error occurs.
* doc/coreutils.texi (tty invocation): Document new behavior.
* init.cfg (stderr_fileno_):
Don't assume have_input_tty is not in the environment.
* src/tty.c (TTY_STDIN_ERROR): New constant.
(main): Exit with nonzero status if there is a usage error,
like other coreutils programs.
Check for error in getting stdin type.
* tests/misc/tty.sh: New file.
* tests/local.mk (all_tests): Add it.
doc/coreutils.texi
init.cfg
src/tty.c
tests/local.mk
tests/misc/tty.sh [new file with mode: 0755]