(old_tty_valid): New variable.
authorKarl Heuer <kwzh@gnu.org>
Mon, 5 Jun 1995 12:35:03 +0000 (12:35 +0000)
committerKarl Heuer <kwzh@gnu.org>
Mon, 5 Jun 1995 12:35:03 +0000 (12:35 +0000)
(init_sys_modes): Set old_tty_valid if we set old_tty.
(reset_sys_modes): Restore tty settings only if old_tty_valid.

src/sysdep.c

index 41bbd92..9d352ab 100644 (file)
@@ -1130,7 +1130,11 @@ emacs_set_tty (fd, settings, waitp)
 /* The initial tty mode bits */
 struct emacs_tty old_tty;
 
-int term_initted;              /* 1 if outer tty status has been recorded */
+/* 1 if we have been through init_sys_modes.  */
+int term_initted;
+
+/* 1 if outer tty status has been recorded.  */
+int old_tty_valid;
 
 #ifdef BSD4_1
 /* BSD 4.1 needs to keep track of the lmode bits in order to start
@@ -1220,6 +1224,8 @@ init_sys_modes ()
     {
       EMACS_GET_TTY (input_fd, &old_tty);
 
+      old_tty_valid = 1;
+
       tty = old_tty;
 
 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
@@ -1650,8 +1656,9 @@ reset_sys_modes ()
     reset_sigio ();
 #endif /* BSD4_1 */
 
-  while (EMACS_SET_TTY (input_fd, &old_tty, 0) < 0 && errno == EINTR)
-    ;
+  if (old_tty_valid)
+    while (EMACS_SET_TTY (input_fd, &old_tty, 0) < 0 && errno == EINTR)
+      ;
 
 #ifdef MSDOS   /* Demacs 1.1.2 91/10/20 Manabu Higashida */
   dos_ttcooked ();