bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] gawk 4.0.1: support for posix_openpt()


From: Christian Weisgerber
Subject: [bug-gawk] gawk 4.0.1: support for posix_openpt()
Date: Sat, 8 Dec 2012 21:27:21 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Currently gawk tries to open PTYs either by cloning from /dev/ptmx
or by falling back to trying /dev/pty* devices.

It would be nice if the posix_openpt() POSIX API was supported, for
platforms like OpenBSD-current that implement it but don't have
/dev/ptmx.

--- configure.ac.orig   Sat Dec  8 16:02:43 2012
+++ configure.ac        Sat Dec  8 16:03:03 2012
@@ -265,7 +265,7 @@ esac
 AC_CHECK_FUNCS(atexit btowc fmod getgrent getgroups grantpt \
        isascii iswctype iswlower iswupper mbrlen \
        memcmp memcpy memcpy_ulong memmove memset \
-       memset_ulong mkstemp setenv setlocale setsid snprintf strchr \
+       memset_ulong mkstemp posix_openpt setenv setlocale setsid snprintf 
strchr \
        strerror strftime strncasecmp strcoll strtod strtoul \
        system tmpfile towlower towupper tzset usleep wcrtomb \
        wcscoll wctype)
--- io.c.orig   Sat Dec  8 16:04:24 2012
+++ io.c        Sat Dec  8 16:05:39 2012
@@ -1598,7 +1598,7 @@ two_way_open(const char *str, struct redirect *rp)
        if (! no_ptys && pty_vs_pipe(str)) {
                static int initialized = FALSE;
                static char first_pty_letter;
-#ifdef HAVE_GRANTPT
+#if defined(HAVE_GRANTPT) && ! defined(HAVE_POSIX_OPENPT)
                static int have_dev_ptmx;
 #endif
                char slavenam[32];
@@ -1615,7 +1615,7 @@ two_way_open(const char *str, struct redirect *rp)
 
                if (! initialized) {
                        initialized = TRUE;
-#ifdef HAVE_GRANTPT
+#if defined(HAVE_GRANTPT) && ! defined(HAVE_POSIX_OPENPT)
                        have_dev_ptmx = (stat("/dev/ptmx", &statb) >= 0);
 #endif
                        i = 0;
@@ -1630,8 +1630,13 @@ two_way_open(const char *str, struct redirect *rp)
                }
 
 #ifdef HAVE_GRANTPT
+#ifdef HAVE_POSIX_OPENPT
+               {
+                       master = posix_openpt(O_RDWR|O_NOCTTY);
+#else
                if (have_dev_ptmx) {
                        master = open("/dev/ptmx", O_RDWR);
+#endif
                        if (master >= 0) {
                                char *tem;
 
-- 
Christian "naddy" Weisgerber                          address@hidden



reply via email to

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