aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/ttyname_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/ttyname_r.c')
-rw-r--r--sysdeps/unix/sysv/linux/ttyname_r.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c
index cef8624dc6..bd415f167b 100644
--- a/sysdeps/unix/sysv/linux/ttyname_r.c
+++ b/sysdeps/unix/sysv/linux/ttyname_r.c
@@ -22,7 +22,6 @@
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
@@ -116,11 +115,11 @@ __ttyname_r (int fd, char *buf, size_t buflen)
return ERANGE;
}
- /* isatty check, tcgetattr is used because it sets the correct
- errno (EBADF resp. ENOTTY) on error. */
- struct termios term;
- if (__builtin_expect (__tcgetattr (fd, &term) < 0, 0))
- return errno;
+ if (__builtin_expect (!__isatty (fd), 0))
+ {
+ __set_errno (ENOTTY);
+ return ENOTTY;
+ }
/* We try using the /proc filesystem. */
*_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0';