diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-12-05 21:28:15 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-12-05 21:28:15 +0000 |
commit | f0d5e1f67bf5d856f7dad926746ca7170560e65f (patch) | |
tree | 5c392aa4d0baa98aa814e249b0341af60b60dfda /sysdeps/unix/sysv/linux/ttyname.c | |
parent | 30a58e6599d9d8419006eb12e413854674ab2f24 (diff) | |
download | glibc-f0d5e1f67bf5d856f7dad926746ca7170560e65f.tar.gz glibc-f0d5e1f67bf5d856f7dad926746ca7170560e65f.tar.xz glibc-f0d5e1f67bf5d856f7dad926746ca7170560e65f.zip |
* nis/nis_subr.c (nis_getnames): Revert last change. cvs/fedora-glibc-20061205T2141
2006-12-04 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/ttyname.c: Include termios.h. (ttyname): Use tcgetattr instead of isatty, don't set errno to ENOTTY. * sysdeps/unix/sysv/linux/ttyname_r.c: Include termios.h. (__ttyname_r): Use tcgetattr instead of isatty, don't set errno to ENOTTY. * io/Makefile: Add rules to build and run tst-ttyname_r test. * io/tst-ttyname_r.c: New test.
Diffstat (limited to 'sysdeps/unix/sysv/linux/ttyname.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/ttyname.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index aed0fd8e0a..1b79787515 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -22,6 +22,7 @@ #include <dirent.h> #include <sys/types.h> #include <sys/stat.h> +#include <termios.h> #include <unistd.h> #include <string.h> #include <stdlib.h> @@ -118,12 +119,12 @@ ttyname (int fd) int dostat = 0; char *name; int save = errno; + struct termios term; - if (__builtin_expect (!__isatty (fd), 0)) - { - __set_errno (ENOTTY); - return NULL; - } + /* isatty check, tcgetattr is used because it sets the correct + errno (EBADF resp. ENOTTY) on error. */ + if (__builtin_expect (__tcgetattr (fd, &term) < 0, 0)) + return NULL; /* We try using the /proc filesystem. */ *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0'; |