diff options
author | Thomas Wouters <thomas@python.org> | 2000-07-14 14:28:33 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2000-07-14 14:28:33 (GMT) |
commit | 70c21a1603091d58036ea6b91f106496d20f12f4 (patch) | |
tree | 30148a8b1a4a47822fa71d5980a4899feadbfa0d | |
parent | 649685ad9bc03b8d7576f7bf8418dce34a5060ad (diff) | |
download | cpython-70c21a1603091d58036ea6b91f106496d20f12f4.zip cpython-70c21a1603091d58036ea6b91f106496d20f12f4.tar.gz cpython-70c21a1603091d58036ea6b91f106496d20f12f4.tar.bz2 |
Move (actually copy) support for the sgi._getpty() function into
posix.openpty(). And conveniently also check if CVS write access really
works.
Closes SF patch #100722
-rw-r--r-- | Modules/posixmodule.c | 29 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | configure.in | 2 |
3 files changed, 27 insertions, 8 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 5b4a867..93f9ea9 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1706,9 +1706,9 @@ extern int openpty(int *, int *, char *, struct termios *, struct winsize *); extern int forkpty(int *, char *, struct termios *, struct winsize *); #endif /* HAVE_LIBUTIL_H */ #endif /* HAVE_PTY_H */ -#endif /* defined(HAVE_OPENPTY) or defined(HAVE_FORKPTY) */ +#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ -#ifdef HAVE_OPENPTY +#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) static char posix_openpty__doc__[] = "openpty() -> (master_fd, slave_fd)\n\ Open a pseudo-terminal, returning open fd's for both master and slave end.\n"; @@ -1717,13 +1717,32 @@ static PyObject * posix_openpty(PyObject *self, PyObject *args) { int master_fd, slave_fd; +#ifndef HAVE_OPENPTY + char * slave_name; + /* SGI apparently needs this forward declaration */ + extern char * _getpty(int *, int, mode_t, int); +#endif + if (!PyArg_ParseTuple(args, ":openpty")) return NULL; + +#ifdef HAVE_OPENPTY if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0) return posix_error(); +#else + slave_name = _getpty(&master_fd, O_RDWR, 0666, 0); + if (slave_name == NULL) + return posix_error(); + + slave_fd = open(slave_name, O_RDWR); + if (slave_fd < 0) + return posix_error(); +#endif /* defined(HAVE_OPENPTY) */ + return Py_BuildValue("(ii)", master_fd, slave_fd); + } -#endif +#endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) */ #ifdef HAVE_FORKPTY static char posix_forkpty__doc__[] = @@ -4926,9 +4945,9 @@ static PyMethodDef posix_methods[] = { #ifdef HAVE_FORK {"fork", posix_fork, METH_VARARGS, posix_fork__doc__}, #endif /* HAVE_FORK */ -#ifdef HAVE_OPENPTY +#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) {"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__}, -#endif /* HAVE_OPENPTY */ +#endif /* HAVE_OPENPTY || HAVE__GETPTY */ #ifdef HAVE_FORKPTY {"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__}, #endif /* HAVE_FORKPTY */ @@ -1,6 +1,6 @@ #! /bin/sh -# From configure.in Revision: 1.136 +# From configure.in Revision: 1.137 # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 @@ -3645,7 +3645,7 @@ for ac_func in alarm chown clock confstr ctermid ctermid_r dlopen execv \ setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf \ sigaction siginterrupt sigrelse strftime strptime symlink sysconf \ tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ - truncate uname waitpid + truncate uname waitpid _getpty do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3652: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 8315ca2..7a819e4 100644 --- a/configure.in +++ b/configure.in @@ -826,7 +826,7 @@ AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r dlopen execv \ setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf \ sigaction siginterrupt sigrelse strftime strptime symlink sysconf \ tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ - truncate uname waitpid) + truncate uname waitpid _getpty) # check for openpty and forkpty |