bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ptsname on Solaris


From: Bruno Haible
Subject: ptsname on Solaris
Date: Sat, 25 Dec 2010 19:20:35 +0100
User-agent: KMail/1.9.9

On Solaris 8..11, the ptsname test fails:

  test-ptsname.c:99: assertion failed
  FAIL: test-ptsname

Apparently ptsname() does not work on any BSD style pty files (/dev/pty??).
Instead one has to use the recommended way to get a pty file descriptor;
then ptsname works.

This patch fixes the test failure.


2010-12-25  Bruno Haible  <address@hidden>

        ptsname test: Avoid failure on Solaris.
        * tests/test-ptsname.c (main): For Solaris, use the recommended way to
        open a pseudo-terminal; don't use BSD-style ptys.
        * doc/posix-functions/ptsname.texi: Document the limitation on Solaris.

--- doc/posix-functions/ptsname.texi.orig       Sat Dec 25 19:16:13 2010
+++ doc/posix-functions/ptsname.texi    Sat Dec 25 19:13:47 2010
@@ -15,4 +15,7 @@
 
 Portability problems not fixed by Gnulib:
 @itemize
address@hidden
+On Solaris 11 2010-11, this function fails on all BSD-style @file{/dev/pty*}
+device files.
 @end itemize
--- tests/test-ptsname.c.orig   Sat Dec 25 19:16:13 2010
+++ tests/test-ptsname.c        Sat Dec 25 19:11:51 2010
@@ -77,6 +77,30 @@
     close (fd);
   }
 
+#if defined __sun
+  /* Solaris has BSD-style /dev/pty[p-r][0-9a-f] files, but the function
+     ptsname() does not work on them.  */
+  {
+    int fd;
+    char *result;
+
+    /* Open the controlling tty of the current process.  */
+    fd = open ("/dev/ptmx", O_RDWR | O_NOCTTY);
+    if (fd < 0)
+      {
+        fprintf (stderr, "Skipping test: cannot open pseudo-terminal\n");
+        return 77;
+      }
+
+    result = ptsname (fd);
+    ASSERT (result != NULL);
+    ASSERT (memcmp (result, "/dev/pts/", 9) == 0);
+
+    close (fd);
+  }
+
+#else
+
   /* Try various master names of MacOS X: /dev/pty[p-w][0-9a-f]  */
   {
     int char1;
@@ -135,5 +159,7 @@
           }
   }
 
+#endif
+
   return 0;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]