summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/posixmodule.c46
-rwxr-xr-xconfigure23
-rw-r--r--configure.in11
-rw-r--r--pyconfig.h.in3
6 files changed, 76 insertions, 10 deletions
diff --git a/Misc/ACKS b/Misc/ACKS
index d5b1f25..839f8ed 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -512,6 +512,7 @@ Casper Stoel
Peter Stoehr
Ken Stox
Daniel Stutzbach
+Paul Swartz
William Tanksley
Christian Tanzer
Amy Taylor
diff --git a/Misc/NEWS b/Misc/NEWS
index 9ffc915..a5dbd94 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -359,6 +359,8 @@ Core and builtins
Extension modules
-----------------
+- posix.openpty now works on all systems that have /dev/ptmx.
+
- A module zipimport exists to support importing code from zip
archives.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 1d8697e..646229e 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2718,7 +2718,7 @@ posix_fork(PyObject *self, PyObject *args)
}
#endif
-#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
+#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX)
#ifdef HAVE_PTY_H
#include <pty.h>
#else
@@ -2726,9 +2726,12 @@ posix_fork(PyObject *self, PyObject *args)
#include <libutil.h>
#endif /* HAVE_LIBUTIL_H */
#endif /* HAVE_PTY_H */
-#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
+#ifdef sun
+#include <sys/stropts.h>
+#endif
+#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX */
-#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY)
+#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)
PyDoc_STRVAR(posix_openpty__doc__,
"openpty() -> (master_fd, slave_fd)\n\n\
Open a pseudo-terminal, returning open fd's for both master and slave end.\n");
@@ -2740,6 +2743,12 @@ posix_openpty(PyObject *self, PyObject *args)
#ifndef HAVE_OPENPTY
char * slave_name;
#endif
+#if defined(HAVE_DEV_PTMX) && !defined(HAVE_OPENPTY) && !defined(HAVE__GETPTY)
+ void *sig_saved;
+#ifdef sun
+ extern char *ptsname();
+#endif
+#endif
if (!PyArg_ParseTuple(args, ":openpty"))
return NULL;
@@ -2747,7 +2756,7 @@ posix_openpty(PyObject *self, PyObject *args)
#ifdef HAVE_OPENPTY
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
return posix_error();
-#else
+#elif HAVE__GETPTY
slave_name = _getpty(&master_fd, O_RDWR, 0666, 0);
if (slave_name == NULL)
return posix_error();
@@ -2755,12 +2764,35 @@ posix_openpty(PyObject *self, PyObject *args)
slave_fd = open(slave_name, O_RDWR);
if (slave_fd < 0)
return posix_error();
+#else
+ master_fd = open("/dev/ptmx", O_RDWR | O_NOCTTY); /* open master */
+ if (master_fd < 0)
+ return posix_error();
+ sig_saved = signal(SIGCHLD, SIG_DFL);
+ if (grantpt(master_fd) < 0) /* change permission of slave */
+ return posix_error();
+ if (unlockpt(master_fd) < 0) /* unlock slave */
+ return posix_error();
+ signal(SIGCHLD, sig_saved);
+ slave_name = ptsname(master_fd); /* get name of slave */
+ if (slave_name == NULL)
+ return posix_error();
+ slave_fd = open(slave_name, O_RDWR | O_NOCTTY); /* open slave */
+ if (slave_fd < 0)
+ return posix_error();
+#ifndef __CYGWIN__
+ ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */
+ ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */
+#ifndef _hpux
+ ioctl(slave_fd, I_PUSH, "ttcompat"); /* push ttcompat */
+#endif /* _hpux */
+#endif /* HAVE_CYGWIN */
#endif /* HAVE_OPENPTY */
return Py_BuildValue("(ii)", master_fd, slave_fd);
}
-#endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) */
+#endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) */
#ifdef HAVE_FORKPTY
PyDoc_STRVAR(posix_forkpty__doc__,
@@ -7229,9 +7261,9 @@ static PyMethodDef posix_methods[] = {
#ifdef HAVE_FORK
{"fork", posix_fork, METH_VARARGS, posix_fork__doc__},
#endif /* HAVE_FORK */
-#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY)
+#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)
{"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__},
-#endif /* HAVE_OPENPTY || HAVE__GETPTY */
+#endif /* HAVE_OPENPTY || HAVE__GETPTY || HAVE_DEV_PTMX */
#ifdef HAVE_FORKPTY
{"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__},
#endif /* HAVE_FORKPTY */
diff --git a/configure b/configure
index 5ef2ea2..86d9578 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 1.380 .
+# From configure.in Revision: 1.381 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.53 for python 2.3.
#
@@ -908,7 +908,7 @@ esac
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
# absolute.
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
-ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
@@ -16657,6 +16657,23 @@ _ACEOF
fi
+echo "$as_me:$LINENO: checking for /dev/ptmx" >&5
+echo $ECHO_N "checking for /dev/ptmx... $ECHO_C" >&6
+
+if test -e /dev/ptmx
+then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DEV_PTMX 1
+_ACEOF
+
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
echo "$as_me:$LINENO: checking for socklen_t" >&5
echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6
if test "${ac_cv_type_socklen_t+set}" = set; then
@@ -17483,7 +17500,7 @@ esac
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
# absolute.
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
-ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
diff --git a/configure.in b/configure.in
index e461658..48fa694 100644
--- a/configure.in
+++ b/configure.in
@@ -2486,6 +2486,17 @@ then
[Define if WINDOW in curses.h offers a field _flags.])
fi
+AC_MSG_CHECKING(for /dev/ptmx)
+
+if test -e /dev/ptmx
+then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_DEV_PTMX, 1,
+ [Define if we have /dev/ptmx.])
+else
+ AC_MSG_RESULT(no)
+fi
+
AC_CHECK_TYPE(socklen_t,,
AC_DEFINE(socklen_t,int,
Define to `int' if <sys/socket.h> does not define.),[
diff --git a/pyconfig.h.in b/pyconfig.h.in
index 922147e..56a5c75 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -65,6 +65,9 @@
/* Define to 1 if you have the device macros. */
#undef HAVE_DEVICE_MACROS
+/* Define if we have /dev/ptmx. */
+#undef HAVE_DEV_PTMX
+
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H