summaryrefslogtreecommitdiffstats
path: root/Lib/pty.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-07-28 09:42:57 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-07-28 09:42:57 (GMT)
commit6c611fae53eeb2e4e5c2db4fc634779fbcdf33eb (patch)
treeb68bdbdbd3d832aadf493fcb7955e45bf2dcbf68 /Lib/pty.py
parentd694c1faf9314c9c531db59d24f90223cf720583 (diff)
downloadcpython-6c611fae53eeb2e4e5c2db4fc634779fbcdf33eb.zip
cpython-6c611fae53eeb2e4e5c2db4fc634779fbcdf33eb.tar.gz
cpython-6c611fae53eeb2e4e5c2db4fc634779fbcdf33eb.tar.bz2
Patch #581705: Catch OSError, termios.error in spawn. 2.2 bugfix candidate.
Diffstat (limited to 'Lib/pty.py')
-rw-r--r--Lib/pty.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/pty.py b/Lib/pty.py
index a2f21c9..a08aa1b 100644
--- a/Lib/pty.py
+++ b/Lib/pty.py
@@ -154,9 +154,14 @@ def spawn(argv, master_read=_read, stdin_read=_read):
pid, master_fd = fork()
if pid == CHILD:
apply(os.execlp, (argv[0],) + argv)
- mode = tty.tcgetattr(STDIN_FILENO)
- tty.setraw(STDIN_FILENO)
+ try:
+ mode = tty.tcgetattr(STDIN_FILENO)
+ tty.setraw(STDIN_FILENO)
+ restore = 1
+ except tty.error: # This is the same as termios.error
+ restore = 0
try:
_copy(master_fd, master_read, stdin_read)
- except IOError:
- tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)
+ except (IOError, OSError):
+ if restore:
+ tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)