comparison 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
comparison
equal deleted inserted replaced
83011:c4d4cbf86260 83012:4aa172a45af1
10277 interrupt_signal (signalnum) /* If we don't have an argument, */ 10277 interrupt_signal (signalnum) /* If we don't have an argument, */
10278 int signalnum; /* some compilers complain in signal calls. */ 10278 int signalnum; /* some compilers complain in signal calls. */
10279 { 10279 {
10280 /* Must preserve main program's value of errno. */ 10280 /* Must preserve main program's value of errno. */
10281 int old_errno = errno; 10281 int old_errno = errno;
10282 struct display *display;
10282 10283
10283 #if defined (USG) && !defined (POSIX_SIGNALS) 10284 #if defined (USG) && !defined (POSIX_SIGNALS)
10284 /* USG systems forget handlers when they are used; 10285 /* USG systems forget handlers when they are used;
10285 must reestablish each time */ 10286 must reestablish each time */
10286 signal (SIGINT, interrupt_signal); 10287 signal (SIGINT, interrupt_signal);
10287 signal (SIGQUIT, interrupt_signal); 10288 signal (SIGQUIT, interrupt_signal);
10288 #endif /* USG */ 10289 #endif /* USG */
10289 10290
10290 if (! tty_list) 10291 /* See if we have a display on our controlling terminal. */
10291 { 10292 display = get_named_tty_display (NULL);
10292 /* If there are no tty frames, exit Emacs. 10293 if (!display)
10293 10294 {
10294 Emacs should exit on SIGINT if and only if there are no 10295 /* If there are no frames there, let's pretend that we are a
10295 frames on its controlling tty and the signal came from there. 10296 well-behaving UN*X program and quit. */
10296 We can check for the first condition, but (alas) not for the
10297 second. The best we can do is that we only exit if we are
10298 sure that the SIGINT was from the controlling tty, i.e., if
10299 there are no termcap frames.
10300 */
10301 Fkill_emacs (Qnil); 10297 Fkill_emacs (Qnil);
10298 }
10299 else
10300 {
10301 /* Otherwise, the SIGINT was probably generated by C-g. */
10302 10302
10303 errno = old_errno; 10303 /* Set internal_last_event_frame to the top frame of the
10304 return; 10304 controlling tty, if we have a frame there. We disable the
10305 } 10305 interrupt key on secondary ttys, so the SIGINT must have come
10306 10306 from the controlling tty. */
10307 handle_interrupt (); 10307 internal_last_event_frame = display->display_info.tty->top_frame;
10308
10309 handle_interrupt ();
10310
10311 }
10308 10312
10309 errno = old_errno; 10313 errno = old_errno;
10310 } 10314 }
10311 10315
10312 /* C-g processing, signal independent code. 10316 /* C-g processing, signal independent code.
10435 /* Else request quit when it's safe */ 10439 /* Else request quit when it's safe */
10436 Vquit_flag = Qt; 10440 Vquit_flag = Qt;
10437 } 10441 }
10438 10442
10439 if (waiting_for_input && !echoing) 10443 if (waiting_for_input && !echoing)
10440 quit_throw_to_read_char (); 10444 quit_throw_to_read_char ();
10441 } 10445 }
10442 10446
10443 /* Handle a C-g by making read_char return C-g. */ 10447 /* Handle a C-g by making read_char return C-g. */
10444 10448
10445 void 10449 void
10698 { 10702 {
10699 /* Before multi-tty support, these handlers used to be installed 10703 /* Before multi-tty support, these handlers used to be installed
10700 only if the current session was a tty session. Now an Emacs 10704 only if the current session was a tty session. Now an Emacs
10701 session may have multiple display types, so we always handle 10705 session may have multiple display types, so we always handle
10702 SIGINT. There is special code in interrupt_signal to exit 10706 SIGINT. There is special code in interrupt_signal to exit
10703 Emacs on SIGINT when there are no termcap frames. */ 10707 Emacs on SIGINT when there are no termcap frames on the
10708 controlling terminal. */
10704 signal (SIGINT, interrupt_signal); 10709 signal (SIGINT, interrupt_signal);
10705 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) 10710 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
10706 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and 10711 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
10707 SIGQUIT and we can't tell which one it will give us. */ 10712 SIGQUIT and we can't tell which one it will give us. */
10708 signal (SIGQUIT, interrupt_signal); 10713 signal (SIGQUIT, interrupt_signal);