diff options
| author | Pádraig Brady <P@draigBrady.com> | 2017-08-30 00:55:34 -0700 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2017-08-30 01:29:53 -0700 |
| commit | d95294982960a4a81889722fd79f1fedc04c8ee5 (patch) | |
| tree | 05292d5a7493b9a2db27bee5528cb76fb92aea59 | |
| parent | runcon: revert "disable use of the TIOCSTI ioctl" (diff) | |
| download | coreutils-d95294982960a4a81889722fd79f1fedc04c8ee5.tar.gz coreutils-d95294982960a4a81889722fd79f1fedc04c8ee5.zip | |
tty: fix exit code with EINVAL
* src/tty.c (main): All systems mention that isatty()
man return EINVAL as well as (the POSIX compliant) ENOTTY.
Also Centos 6 was seen to return EINVAL from ttyname().
* tests/misc/tty.sh: Fix a test issue where we assume
standard input is always a valid tty.
Reported by Assaf Gordon on OpenSolaris 5.10 and 5.11,
and Centos 6.5
| -rw-r--r-- | src/tty.c | 4 | ||||
| -rwxr-xr-x | tests/misc/tty.sh | 4 |
2 files changed, 5 insertions, 3 deletions
@@ -119,7 +119,7 @@ main (int argc, char **argv) if (silent) return (isatty (STDIN_FILENO) ? EXIT_SUCCESS - : errno == ENOTTY ? TTY_STDIN_NOTTY + : (errno == ENOTTY || errno == EINVAL) ? TTY_STDIN_NOTTY : TTY_STDIN_ERROR); int status = EXIT_SUCCESS; @@ -127,7 +127,7 @@ main (int argc, char **argv) if (! tty) { - if (errno != ENOTTY) + if (errno != ENOTTY && errno != EINVAL) error (TTY_STDIN_ERROR, errno, _("standard input")); tty = _("not a tty"); status = TTY_STDIN_NOTTY; diff --git a/tests/misc/tty.sh b/tests/misc/tty.sh index 5931350ef..904b5d6a2 100755 --- a/tests/misc/tty.sh +++ b/tests/misc/tty.sh @@ -32,7 +32,9 @@ returns_ 2 tty a || fail=1 returns_ 2 tty -s a || fail=1 if test -w /dev/full && test -c /dev/full; then - returns_ 3 tty >/dev/full || fail=1 + if test -t 0; then + returns_ 3 tty >/dev/full || fail=1 + fi returns_ 3 tty </dev/null >/dev/full || fail=1 fi |
