diff src/keyboard.c @ 83012:4aa172a45af1

Fix C-g handling with multiple ttys. src/sysdep.c (init_sys_modes): Disable interrupt and quit keys on secondary terminals. Added a big fat comment about this. lib-src/emacsclient.c (init_signals): Don't pass SIGINT and SIGQUIT to Emacs. src/keyboard.c (interrupt_signal): Exit Emacs if there are no frames on the controlling tty. Otherwise set internal_last_event_frame to the controlling tty's top frame. src/term.c (ring_bell, tty_ring_bell): Don't look at updating_frame. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-52
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 11 Jan 2004 02:45:44 +0000
parents c4d4cbf86260
children f5cadabb36dd
line wrap: on
line diff
--- a/src/keyboard.c	Sun Jan 11 01:18:45 2004 +0000
+++ b/src/keyboard.c	Sun Jan 11 02:45:44 2004 +0000
@@ -10279,6 +10279,7 @@
 {
   /* Must preserve main program's value of errno.  */
   int old_errno = errno;
+  struct display *display;
 
 #if defined (USG) && !defined (POSIX_SIGNALS)
   /* USG systems forget handlers when they are used;
@@ -10287,24 +10288,27 @@
   signal (SIGQUIT, interrupt_signal);
 #endif /* USG */
 
-  if (! tty_list)
-    {
-      /* If there are no tty frames, exit Emacs.
-
-         Emacs should exit on SIGINT if and only if there are no
-         frames on its controlling tty and the signal came from there.
-         We can check for the first condition, but (alas) not for the
-         second.  The best we can do is that we only exit if we are
-         sure that the SIGINT was from the controlling tty, i.e., if
-         there are no termcap frames.
-      */
+  /* See if we have a display on our controlling terminal. */
+  display = get_named_tty_display (NULL);
+  if (!display)
+    {
+      /* If there are no frames there, let's pretend that we are a
+         well-behaving UN*X program and quit. */
       Fkill_emacs (Qnil);
+    }
+  else
+    {
+      /* Otherwise, the SIGINT was probably generated by C-g.  */
       
-      errno = old_errno;
-      return;
-    }
-
-  handle_interrupt ();
+      /* Set internal_last_event_frame to the top frame of the
+         controlling tty, if we have a frame there.  We disable the
+         interrupt key on secondary ttys, so the SIGINT must have come
+         from the controlling tty.  */
+      internal_last_event_frame = display->display_info.tty->top_frame;
+
+      handle_interrupt ();
+
+    }
 
   errno = old_errno;
 }
@@ -10437,7 +10441,7 @@
     }
 
   if (waiting_for_input && !echoing)
-    quit_throw_to_read_char ();
+      quit_throw_to_read_char ();
 }
 
 /* Handle a C-g by making read_char return C-g.  */
@@ -10700,7 +10704,8 @@
          only if the current session was a tty session.  Now an Emacs
          session may have multiple display types, so we always handle
          SIGINT.  There is special code in interrupt_signal to exit
-         Emacs on SIGINT when there are no termcap frames. */
+         Emacs on SIGINT when there are no termcap frames on the
+         controlling terminal. */
       signal (SIGINT, interrupt_signal);
 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
       /* For systems with SysV TERMIO, C-g is set up for both SIGINT and