about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/ttyname.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-03-05 18:52:41 +0000
committerUlrich Drepper <drepper@redhat.com>1999-03-05 18:52:41 +0000
commitaad20af475f8e3e1d7d878e82d82d433706ffaff (patch)
tree057adf49a680a45aa17b8d2c8fa1c0103a7e77c4 /sysdeps/unix/sysv/linux/ttyname.c
parentc277d2e55aea93070df74a1b8b7fcc6c44534254 (diff)
downloadglibc-aad20af475f8e3e1d7d878e82d82d433706ffaff.tar.gz
glibc-aad20af475f8e3e1d7d878e82d82d433706ffaff.tar.xz
glibc-aad20af475f8e3e1d7d878e82d82d433706ffaff.zip
Update.
	* sysdeps/unix/sysv/linux/ttyname_r.c (__ttyname_r): Remember
	whether /dev/pts is available.
	* sysdeps/unix/sysv/linux/ttyname.c (ttyname): Fix handling of
	dev_pts_available.
Diffstat (limited to 'sysdeps/unix/sysv/linux/ttyname.c')
-rw-r--r--sysdeps/unix/sysv/linux/ttyname.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c
index a32d1a6605..9d345b8b94 100644
--- a/sysdeps/unix/sysv/linux/ttyname.c
+++ b/sysdeps/unix/sysv/linux/ttyname.c
@@ -111,7 +111,7 @@ ttyname (fd)
   char procname[30];
   struct stat st, st1;
   int dostat = 0;
-  char *name;
+  char *name = NULL;
   int save = errno;
 
   if (!__isatty (fd))
@@ -139,20 +139,21 @@ ttyname (fd)
   if (__fxstat (_STAT_VER, fd, &st) < 0)
     return NULL;
 
-  if (dev_pts_available
-      && __xstat (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
+  if (dev_pts_available)
     {
+      if (__xstat (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
+	{
 #ifdef _STATBUF_ST_RDEV
-      name = getttyname ("/dev/pts", st.st_rdev, st.st_ino, save, &dostat);
+	  name = getttyname ("/dev/pts", st.st_rdev, st.st_ino, save, &dostat);
 #else
-      name = getttyname ("/dev/pts", st.st_dev, st.st_ino, save, &dostat);
+	  name = getttyname ("/dev/pts", st.st_dev, st.st_ino, save, &dostat);
 #endif
-    }
-  else
-    {
-      __set_errno (save);
-      name = NULL;
-      dev_pts_available = 1;
+	}
+      else
+	{
+	  __set_errno (save);
+	  dev_pts_available = 0;
+	}
     }
 
   if (!name && dostat != -1)