Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: third_party/pexpect/notes/posixmodule.c.diff

Issue 1398903002: Add third_party/pexpect (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@end-to-end-test
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pexpect/notes/notes.txt ('k') | third_party/pexpect/pexpect/ANSI.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pexpect/notes/posixmodule.c.diff
diff --git a/third_party/pexpect/notes/posixmodule.c.diff b/third_party/pexpect/notes/posixmodule.c.diff
new file mode 100644
index 0000000000000000000000000000000000000000..3bea1f9cba96e0701ec64fb3a273e377b6d66d93
--- /dev/null
+++ b/third_party/pexpect/notes/posixmodule.c.diff
@@ -0,0 +1,233 @@
+*** Python-2.2.1.orig/Modules/posixmodule.c Tue Mar 12 16:38:31 2002
+--- Python-2.2.1/Modules/posixmodule.c Tue May 21 01:16:29 2002
+***************
+*** 1904,1910 ****
+ }
+ #endif
+
+! #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
+ #ifdef HAVE_PTY_H
+ #include <pty.h>
+ #else
+--- 1904,1913 ----
+ }
+ #endif
+
+! #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(sun)
+! #ifdef sun
+! #include <sys/stropts.h>
+! #endif
+ #ifdef HAVE_PTY_H
+ #include <pty.h>
+ #else
+***************
+*** 1914,1920 ****
+ #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\
+ Open a pseudo-terminal, returning open fd's for both master and slave end.\n";
+--- 1917,1923 ----
+ #endif /* HAVE_PTY_H */
+ #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
+
+! #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(sun)
+ 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";
+***************
+*** 1925,1932 ****
+ int master_fd, slave_fd;
+ #ifndef HAVE_OPENPTY
+ char * slave_name;
+ #endif
+!
+ if (!PyArg_ParseTuple(args, ":openpty"))
+ return NULL;
+
+--- 1928,1941 ----
+ int master_fd, slave_fd;
+ #ifndef HAVE_OPENPTY
+ char * slave_name;
++ #ifdef sun
++ void *sig_saved;
+ #endif
+! #endif
+! #if !defined(HAVE_OPENPTY) && !defined(HAVE__GETPTY) && defined(sun)
+! extern char *ptsname();
+! #endif
+!
+ if (!PyArg_ParseTuple(args, ":openpty"))
+ return NULL;
+
+***************
+*** 1933,1939 ****
+ #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();
+--- 1942,1948 ----
+ #ifdef HAVE_OPENPTY
+ if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
+ return posix_error();
+! #elif HAVE__GETPTY
+ slave_name = _getpty(&master_fd, O_RDWR, 0666, 0);
+ if (slave_name == NULL)
+ return posix_error();
+***************
+*** 1941,1946 ****
+--- 1950,1966 ----
+ slave_fd = open(slave_name, O_RDWR);
+ if (slave_fd < 0)
+ return posix_error();
++ #else
++ master_fd = open("/dev/ptmx", O_RDWR|O_NOCTTY); /* open master */
++ sig_saved = signal(SIGCHLD, SIG_DFL);
++ grantpt(master_fd); /* change permission of slave */
++ unlockpt(master_fd); /* unlock slave */
++ signal(SIGCHLD,sig_saved);
++ slave_name = ptsname(master_fd); /* get name of slave */
++ slave_fd = open(slave_name, O_RDWR); /* open slave */
++ ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */
++ ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm*/
++ ioctl(slave_fd, I_PUSH, "ttcompat"); /* push ttcompat*/
+ #endif /* HAVE_OPENPTY */
+
+ return Py_BuildValue("(ii)", master_fd, slave_fd);
+***************
+*** 1948,1954 ****
+ }
+ #endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) */
+
+! #ifdef HAVE_FORKPTY
+ static char posix_forkpty__doc__[] =
+ "forkpty() -> (pid, master_fd)\n\
+ Fork a new process with a new pseudo-terminal as controlling tty.\n\n\
+--- 1968,1974 ----
+ }
+ #endif /* defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) */
+
+! #if defined(HAVE_FORKPTY) || defined(sun)
+ static char posix_forkpty__doc__[] =
+ "forkpty() -> (pid, master_fd)\n\
+ Fork a new process with a new pseudo-terminal as controlling tty.\n\n\
+***************
+*** 1959,1968 ****
+--- 1979,2067 ----
+ posix_forkpty(PyObject *self, PyObject *args)
+ {
+ int master_fd, pid;
++ #if defined(sun)
++ int slave;
++ char * slave_name;
++ void *sig_saved;
++ int fd;
++ #endif
+
+ if (!PyArg_ParseTuple(args, ":forkpty"))
+ return NULL;
++ #if defined(sun)
++ master_fd = open("/dev/ptmx", O_RDWR|O_NOCTTY); /* open master */
++ sig_saved = signal(SIGCHLD, SIG_DFL);
++ grantpt(master_fd); /* change permission of slave */
++ unlockpt(master_fd); /* unlock slave */
++ signal(SIGCHLD,sig_saved);
++ slave_name = ptsname(master_fd); /* get name of slave */
++ slave = open(slave_name, O_RDWR); /* open slave */
++ ioctl(slave, I_PUSH, "ptem"); /* push ptem */
++ ioctl(slave, I_PUSH, "ldterm"); /* push ldterm*/
++ ioctl(slave, I_PUSH, "ttcompat"); /* push ttcompat*/
++ if (master_fd < 0 || slave < 0)
++ {
++ return posix_error();
++ }
++ switch (pid = fork()) {
++ case -1:
++ return posix_error();
++ case 0:
++ /* First disconnect from the old controlling tty. */
++ #ifdef TIOCNOTTY
++ fd = open("/dev/tty", O_RDWR | O_NOCTTY);
++ if (fd >= 0) {
++ (void) ioctl(fd, TIOCNOTTY, NULL);
++ close(fd);
++ }
++ #endif /* TIOCNOTTY */
++ if (setsid() < 0)
++ return posix_error();
++
++ /*
++ * Verify that we are successfully disconnected from the controlling
++ * tty.
++ */
++ fd = open("/dev/tty", O_RDWR | O_NOCTTY);
++ if (fd >= 0) {
++ return posix_error();
++ close(fd);
++ }
++ /* Make it our controlling tty. */
++ #ifdef TIOCSCTTY
++ if (ioctl(slave, TIOCSCTTY, NULL) < 0)
++ return posix_error();
++ #endif /* TIOCSCTTY */
++ fd = open(slave_name, O_RDWR);
++ if (fd < 0) {
++ return posix_error();
++ } else {
++ close(fd);
++ }
++ /* Verify that we now have a controlling tty. */
++ fd = open("/dev/tty", O_WRONLY);
++ if (fd < 0)
++ return posix_error();
++ else {
++ close(fd);
++ }
++ (void) close(master_fd);
++ (void) dup2(slave, 0);
++ (void) dup2(slave, 1);
++ (void) dup2(slave, 2);
++ if (slave > 2)
++ (void) close(slave);
++ pid = 0;
++ break;
++ defautlt:
++ /*
++ * parent
++ */
++ (void) close(slave);
++ }
++ #else
+ pid = forkpty(&master_fd, NULL, NULL, NULL);
++ #endif
+ if (pid == -1)
+ return posix_error();
+ if (pid == 0)
+***************
+*** 5607,5616 ****
+ #ifdef HAVE_FORK
+ {"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__},
+ #endif /* HAVE_FORKPTY */
+ #ifdef HAVE_GETEGID
+--- 5706,5715 ----
+ #ifdef HAVE_FORK
+ {"fork", posix_fork, METH_VARARGS, posix_fork__doc__},
+ #endif /* HAVE_FORK */
+! #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(sun)
+ {"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__},
+ #endif /* HAVE_OPENPTY || HAVE__GETPTY */
+! #if defined(HAVE_FORKPTY) || defined(sun)
+ {"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__},
+ #endif /* HAVE_FORKPTY */
+ #ifdef HAVE_GETEGID
« no previous file with comments | « third_party/pexpect/notes/notes.txt ('k') | third_party/pexpect/pexpect/ANSI.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698