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
This commit is contained in:
Thomas Wouters 2000-07-14 14:28:33 +00:00
parent 649685ad9b
commit 70c21a1603
3 changed files with 27 additions and 8 deletions

View 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 */

4
configure vendored
View File

@ -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

View 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