aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-12-09 21:35:46 +0200
committerArnold D. Robbins <arnold@skeeve.com>2012-12-09 21:35:46 +0200
commit134fa0445295460d897661ee18027c645b2baa73 (patch)
tree7af792097e7d23bd9cec91c31dd9e525a62f6245 /io.c
parent4ed8e81f87aadda3521a967b5c5e714bf027194b (diff)
downloadegawk-134fa0445295460d897661ee18027c645b2baa73.tar.gz
egawk-134fa0445295460d897661ee18027c645b2baa73.tar.bz2
egawk-134fa0445295460d897661ee18027c645b2baa73.zip
Use posix_openpt() if available.
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 7 insertions, 2 deletions
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;