aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--configh.in3
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac2
-rw-r--r--io.c9
5 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fba6f20..2c112458 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,13 @@
* main.c (main): Ditto.
* builtin.c (do_system): Ditto.
+ Unrelated:
+
+ * configure.ac: Look for posix_openpt
+ * io.c (two_way_open): Use posix_openpt if it's available.
+ Thanks to Christian Weisgerber <naddy@mips.inka.de> for
+ the changes.
+
2012-12-07 Arnold D. Robbins <arnold@skeeve.com>
* awkgram.y (tokentab): `fflush()' is now in POSIX, remove the
diff --git a/configh.in b/configh.in
index 8cb9826e..627533c3 100644
--- a/configh.in
+++ b/configh.in
@@ -156,6 +156,9 @@
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
+/* Define to 1 if you have the `posix_openpt' function. */
+#undef HAVE_POSIX_OPENPT
+
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
diff --git a/configure b/configure
index 0696cca7..099a1612 100755
--- a/configure
+++ b/configure
@@ -9947,7 +9947,7 @@ esac
for ac_func in 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
diff --git a/configure.ac b/configure.ac
index fbd0232b..2db9ef72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -269,7 +269,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)
diff --git a/io.c b/io.c
index efdec065..4b658950 100644
--- a/io.c
+++ b/io.c
@@ -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;