]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Move (actually copy) support for the sgi._getpty() function into
authorThomas Wouters <thomas@python.org>
Fri, 14 Jul 2000 14:28:33 +0000 (14:28 +0000)
committerThomas Wouters <thomas@python.org>
Fri, 14 Jul 2000 14:28:33 +0000 (14:28 +0000)
posix.openpty(). And conveniently also check if CVS write access really
works.

Closes SF patch #100722

Modules/posixmodule.c
configure
configure.in

index 5b4a8677a0f62de8625af7e78eedc07c287ceb9f..93f9ea9a787ec8f9a1659d3e60deab374096d85c 100644 (file)
@@ -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 */
index 8293ee3a133e1f74848060a632b02d69677f5510..0418b847873f27175e8a0a1baf1d0e1579796a1b 100755 (executable)
--- a/configure
+++ b/configure
@@ -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
index 8315ca289cf26b5bb36ae13c296330eff7776fdf..7a819e4140c04ca464991ced71204d0a97aea1db 100644 (file)
@@ -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