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)