summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-03-21 01:43:31 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-03-21 01:43:31 (GMT)
commitb59798b1573d542016bab989fe8439b10580092c (patch)
tree002effb577e3ddebbaa3f5171deec4a7919bd689
parent865400fd07adfae27c83dbf71e56c202d0420519 (diff)
downloadcpython-b59798b1573d542016bab989fe8439b10580092c.zip
cpython-b59798b1573d542016bab989fe8439b10580092c.tar.gz
cpython-b59798b1573d542016bab989fe8439b10580092c.tar.bz2
Add support for os.openpty() on AIX which uses /dev/ptc instead of /dev/ptmx.
-rw-r--r--Modules/posixmodule.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 37a7d26..4e7f9bc 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2572,6 +2572,14 @@ posix_fork(PyObject *self, PyObject *noargs)
}
#endif
+/* AIX uses /dev/ptc but is otherwise the same as /dev/ptmx */
+#ifdef HAVE_DEV_PTC
+#define DEV_PTY_FILE "/dev/ptc"
+#define HAVE_DEV_PTMX
+#else
+#define DEV_PTY_FILE "/dev/ptmx"
+#endif
+
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX)
#ifdef HAVE_PTY_H
#include <pty.h>
@@ -2607,7 +2615,7 @@ posix_openpty(PyObject *self, PyObject *noargs)
#ifdef HAVE_OPENPTY
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
return posix_error();
-#elif HAVE__GETPTY
+#elif defined(HAVE__GETPTY)
slave_name = _getpty(&master_fd, O_RDWR, 0666, 0);
if (slave_name == NULL)
return posix_error();
@@ -2616,7 +2624,7 @@ posix_openpty(PyObject *self, PyObject *noargs)
if (slave_fd < 0)
return posix_error();
#else
- master_fd = open("/dev/ptmx", O_RDWR | O_NOCTTY); /* open master */
+ master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */
if (master_fd < 0)
return posix_error();
sig_saved = signal(SIGCHLD, SIG_DFL);
@@ -2637,7 +2645,7 @@ posix_openpty(PyObject *self, PyObject *noargs)
slave_fd = open(slave_name, O_RDWR | O_NOCTTY); /* open slave */
if (slave_fd < 0)
return posix_error();
-#ifndef __CYGWIN__
+#if !defined(__CYGWIN__) && !defined(HAVE_DEV_PTC)
ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */
ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */
#ifndef __hpux