[Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.152,2.153
Thomas Wouters
python-dev@python.org
2000年7月14日 07:28:35 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv7380/Modules
Modified Files:
posixmodule.c
Log Message:
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
Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.152
retrieving revision 2.153
diff -C2 -r2.152 -r2.153
*** posixmodule.c 2000年07月13日 01:26:58 2.152
--- posixmodule.c 2000年07月14日 14:28:33 2.153
***************
*** 1707,1713 ****
#endif /* HAVE_LIBUTIL_H */
#endif /* HAVE_PTY_H */
! #endif /* defined(HAVE_OPENPTY) or defined(HAVE_FORKPTY) */
! #ifdef HAVE_OPENPTY
static char posix_openpty__doc__[] =
"openpty() -> (master_fd, slave_fd)\n\
--- 1707,1713 ----
#endif /* HAVE_LIBUTIL_H */
#endif /* HAVE_PTY_H */
! #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
! #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY)
static char posix_openpty__doc__[] =
"openpty() -> (master_fd, slave_fd)\n\
***************
*** 1718,1728 ****
{
int master_fd, slave_fd;
if (!PyArg_ParseTuple(args, ":openpty"))
return NULL;
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
return posix_error();
return Py_BuildValue("(ii)", master_fd, slave_fd);
}
! #endif
#ifdef HAVE_FORKPTY
--- 1718,1747 ----
{
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 /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) */
#ifdef HAVE_FORKPTY
***************
*** 4927,4933 ****
{"fork", posix_fork, METH_VARARGS, posix_fork__doc__},
#endif /* HAVE_FORK */
! #ifdef HAVE_OPENPTY
{"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__},
! #endif /* HAVE_OPENPTY */
#ifdef HAVE_FORKPTY
{"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__},
--- 4946,4952 ----
{"fork", posix_fork, METH_VARARGS, posix_fork__doc__},
#endif /* HAVE_FORK */
! #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY)
{"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__},
! #endif /* HAVE_OPENPTY || HAVE__GETPTY */
#ifdef HAVE_FORKPTY
{"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__},