]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport loewis' 1.12:
authorMichael W. Hudson <mwh@python.net>
Mon, 30 Sep 2002 10:54:15 +0000 (10:54 +0000)
committerMichael W. Hudson <mwh@python.net>
Mon, 30 Sep 2002 10:54:15 +0000 (10:54 +0000)
Patch #581705: Catch OSError, termios.error in spawn. 2.2 bugfix candidate.

Lib/pty.py

index a2f21c9bf6ef44e301ef277b20e768d955ffdcd4..a08aa1ba686bb91d3efb190b093b57989fd91eca 100644 (file)
@@ -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)