mirror of https://github.com/python/cpython
Patch #656590: /dev/ptmx support for ptys.
This commit is contained in:
parent
b70557f13d
commit
24a880b499
|
@ -512,6 +512,7 @@ Casper Stoel
|
||||||
Peter Stoehr
|
Peter Stoehr
|
||||||
Ken Stox
|
Ken Stox
|
||||||
Daniel Stutzbach
|
Daniel Stutzbach
|
||||||
|
Paul Swartz
|
||||||
William Tanksley
|
William Tanksley
|
||||||
Christian Tanzer
|
Christian Tanzer
|
||||||
Amy Taylor
|
Amy Taylor
|
||||||
|
|
|
@ -359,6 +359,8 @@ Core and builtins
|
||||||
Extension modules
|
Extension modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- posix.openpty now works on all systems that have /dev/ptmx.
|
||||||
|
|
||||||
- A module zipimport exists to support importing code from zip
|
- A module zipimport exists to support importing code from zip
|
||||||
archives.
|
archives.
|
||||||
|
|
||||||
|
|
|
@ -2718,7 +2718,7 @@ posix_fork(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
|
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX)
|
||||||
#ifdef HAVE_PTY_H
|
#ifdef HAVE_PTY_H
|
||||||
#include <pty.h>
|
#include <pty.h>
|
||||||
#else
|
#else
|
||||||
|
@ -2726,9 +2726,12 @@ posix_fork(PyObject *self, PyObject *args)
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
#endif /* HAVE_LIBUTIL_H */
|
#endif /* HAVE_LIBUTIL_H */
|
||||||
#endif /* HAVE_PTY_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__,
|
PyDoc_STRVAR(posix_openpty__doc__,
|
||||||
"openpty() -> (master_fd, slave_fd)\n\n\
|
"openpty() -> (master_fd, slave_fd)\n\n\
|
||||||
Open a pseudo-terminal, returning open fd's for both master and slave end.\n");
|
Open a pseudo-terminal, returning open fd's for both master and slave end.\n");
|
||||||
|
@ -2739,6 +2742,12 @@ posix_openpty(PyObject *self, PyObject *args)
|
||||||
int master_fd, slave_fd;
|
int master_fd, slave_fd;
|
||||||
#ifndef HAVE_OPENPTY
|
#ifndef HAVE_OPENPTY
|
||||||
char * slave_name;
|
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
|
#endif
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, ":openpty"))
|
if (!PyArg_ParseTuple(args, ":openpty"))
|
||||||
|
@ -2747,7 +2756,7 @@ posix_openpty(PyObject *self, PyObject *args)
|
||||||
#ifdef HAVE_OPENPTY
|
#ifdef HAVE_OPENPTY
|
||||||
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
|
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
|
||||||
return posix_error();
|
return posix_error();
|
||||||
#else
|
#elif HAVE__GETPTY
|
||||||
slave_name = _getpty(&master_fd, O_RDWR, 0666, 0);
|
slave_name = _getpty(&master_fd, O_RDWR, 0666, 0);
|
||||||
if (slave_name == NULL)
|
if (slave_name == NULL)
|
||||||
return posix_error();
|
return posix_error();
|
||||||
|
@ -2755,12 +2764,35 @@ posix_openpty(PyObject *self, PyObject *args)
|
||||||
slave_fd = open(slave_name, O_RDWR);
|
slave_fd = open(slave_name, O_RDWR);
|
||||||
if (slave_fd < 0)
|
if (slave_fd < 0)
|
||||||
return posix_error();
|
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 */
|
#endif /* HAVE_OPENPTY */
|
||||||
|
|
||||||
return Py_BuildValue("(ii)", master_fd, slave_fd);
|
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
|
#ifdef HAVE_FORKPTY
|
||||||
PyDoc_STRVAR(posix_forkpty__doc__,
|
PyDoc_STRVAR(posix_forkpty__doc__,
|
||||||
|
@ -7229,9 +7261,9 @@ static PyMethodDef posix_methods[] = {
|
||||||
#ifdef HAVE_FORK
|
#ifdef HAVE_FORK
|
||||||
{"fork", posix_fork, METH_VARARGS, posix_fork__doc__},
|
{"fork", posix_fork, METH_VARARGS, posix_fork__doc__},
|
||||||
#endif /* HAVE_FORK */
|
#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__},
|
{"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__},
|
||||||
#endif /* HAVE_OPENPTY || HAVE__GETPTY */
|
#endif /* HAVE_OPENPTY || HAVE__GETPTY || HAVE_DEV_PTMX */
|
||||||
#ifdef HAVE_FORKPTY
|
#ifdef HAVE_FORKPTY
|
||||||
{"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__},
|
{"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__},
|
||||||
#endif /* HAVE_FORKPTY */
|
#endif /* HAVE_FORKPTY */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# From configure.in Revision: 1.380 .
|
# From configure.in Revision: 1.381 .
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.53 for python 2.3.
|
# 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
|
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
|
||||||
# absolute.
|
# absolute.
|
||||||
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
|
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_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
|
||||||
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
||||||
|
|
||||||
|
@ -16657,6 +16657,23 @@ _ACEOF
|
||||||
|
|
||||||
fi
|
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 "$as_me:$LINENO: checking for socklen_t" >&5
|
||||||
echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6
|
echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6
|
||||||
if test "${ac_cv_type_socklen_t+set}" = set; then
|
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
|
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
|
||||||
# absolute.
|
# absolute.
|
||||||
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
|
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_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
|
||||||
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
||||||
|
|
||||||
|
|
11
configure.in
11
configure.in
|
@ -2486,6 +2486,17 @@ then
|
||||||
[Define if WINDOW in curses.h offers a field _flags.])
|
[Define if WINDOW in curses.h offers a field _flags.])
|
||||||
fi
|
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_CHECK_TYPE(socklen_t,,
|
||||||
AC_DEFINE(socklen_t,int,
|
AC_DEFINE(socklen_t,int,
|
||||||
Define to `int' if <sys/socket.h> does not define.),[
|
Define to `int' if <sys/socket.h> does not define.),[
|
||||||
|
|
|
@ -65,6 +65,9 @@
|
||||||
/* Define to 1 if you have the device macros. */
|
/* Define to 1 if you have the device macros. */
|
||||||
#undef HAVE_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'.
|
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
|
||||||
*/
|
*/
|
||||||
#undef HAVE_DIRENT_H
|
#undef HAVE_DIRENT_H
|
||||||
|
|
Loading…
Reference in New Issue