about summary refs log tree commit diff
path: root/sysdeps/posix/ttyname.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix/ttyname.c')
-rw-r--r--sysdeps/posix/ttyname.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c
index b0650b38b0..7c7ed2428a 100644
--- a/sysdeps/posix/ttyname.c
+++ b/sysdeps/posix/ttyname.c
@@ -44,6 +44,9 @@ DEFUN(ttyname, (fd), int fd)
   struct dirent *d;
   int save = errno;
 
+  if (!__isatty (fd))
+    return NULL;
+
   if (fstat (fd, &st) < 0)
     return NULL;
   mydev = st.st_dev;