From: Michael W. Hudson Date: Mon, 30 Sep 2002 10:54:15 +0000 (+0000) Subject: Backport loewis' 1.12: X-Git-Tag: v2.2.2b1~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7da5feb18b4a371efd518e5ef0d5c0a55383ce89;p=thirdparty%2FPython%2Fcpython.git Backport loewis' 1.12: Patch #581705: Catch OSError, termios.error in spawn. 2.2 bugfix candidate. --- diff --git a/Lib/pty.py b/Lib/pty.py index a2f21c9bf6ef..a08aa1ba686b 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)