aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2004-01-11 02:45:44 +0000
committerKaroly Lorentey2004-01-11 02:45:44 +0000
commit4ca927b4e0eb688a0eb224463288443164dd716f (patch)
tree07e786aa4aba5640b38a872163b8960c86368d92 /src
parent8f1ce42333b410e736053a7c5cbbf102032c84f2 (diff)
downloademacs-4ca927b4e0eb688a0eb224463288443164dd716f.tar.gz
emacs-4ca927b4e0eb688a0eb224463288443164dd716f.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c37
-rw-r--r--src/sysdep.c33
-rw-r--r--src/term.c9
3 files changed, 51 insertions, 28 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 7b9ee4513d5..4f262678acf 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10279,6 +10279,7 @@ interrupt_signal (signalnum) /* If we don't have an argument, */
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;
@@ -10287,24 +10288,27 @@ interrupt_signal (signalnum) /* If we don't have an argument, */
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. */
10292 display = get_named_tty_display (NULL);
10293 if (!display)
10291 { 10294 {
10292 /* If there are no tty frames, exit Emacs. 10295 /* If there are no frames there, let's pretend that we are a
10293 10296 well-behaving UN*X program and quit. */
10294 Emacs should exit on SIGINT if and only if there are no
10295 frames on its controlling tty and the signal came from there.
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);
10302
10303 errno = old_errno;
10304 return;
10305 } 10298 }
10299 else
10300 {
10301 /* Otherwise, the SIGINT was probably generated by C-g. */
10302
10303 /* Set internal_last_event_frame to the top frame of the
10304 controlling tty, if we have a frame there. We disable the
10305 interrupt key on secondary ttys, so the SIGINT must have come
10306 from the controlling tty. */
10307 internal_last_event_frame = display->display_info.tty->top_frame;
10308
10309 handle_interrupt ();
10306 10310
10307 handle_interrupt (); 10311 }
10308 10312
10309 errno = old_errno; 10313 errno = old_errno;
10310} 10314}
@@ -10437,7 +10441,7 @@ handle_interrupt ()
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. */
@@ -10700,7 +10704,8 @@ init_keyboard ()
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
diff --git a/src/sysdep.c b/src/sysdep.c
index c3d9ef80b3e..5a2bb449df1 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1453,11 +1453,34 @@ nil means don't delete them until `list-processes' is run. */);
1453 tty.main.c_cflag &= ~PARENB;/* Don't check parity */ 1453 tty.main.c_cflag &= ~PARENB;/* Don't check parity */
1454 } 1454 }
1455#endif 1455#endif
1456 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */ 1456 if (tty_out->input == stdin)
1457 /* Set up C-g for both SIGQUIT and SIGINT. 1457 {
1458 We don't know which we will get, but we handle both alike 1458 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */
1459 so which one it really gives us does not matter. */ 1459 /* Set up C-g for both SIGQUIT and SIGINT.
1460 tty.main.c_cc[VQUIT] = quit_char; 1460 We don't know which we will get, but we handle both alike
1461 so which one it really gives us does not matter. */
1462 tty.main.c_cc[VQUIT] = quit_char;
1463 }
1464 else
1465 {
1466 /* We normally don't get interrupt or quit signals from tty
1467 devices other than our controlling terminal; therefore,
1468 we must handle C-g as normal input. Unfortunately, this
1469 means that the interrupt and quit feature must be
1470 disabled on secondary ttys, or we would not even see the
1471 keypress.
1472
1473 Note that even though emacsclient could have special code
1474 to pass SIGINT to Emacs, we should _not_ enable
1475 interrupt/quit keys for emacsclient frames. This means
1476 that we can't break out of loops in C code from a
1477 secondary tty frame, but we can always decide what
1478 display the C-g came from, which is more important from a
1479 usability point of view. (Consider the case when two
1480 people work together using the same Emacs instance.) */
1481 tty.main.c_cc[VINTR] = CDISABLE;
1482 tty.main.c_cc[VQUIT] = CDISABLE;
1483 }
1461 tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */ 1484 tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */
1462 tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */ 1485 tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */
1463#ifdef VSWTCH 1486#ifdef VSWTCH
diff --git a/src/term.c b/src/term.c
index a988b7d92e8..3ab02c501b8 100644
--- a/src/term.c
+++ b/src/term.c
@@ -176,9 +176,7 @@ extern char *tgetstr ();
176void 176void
177ring_bell () 177ring_bell ()
178{ 178{
179 struct frame *f = (updating_frame 179 struct frame *f = XFRAME (selected_frame);
180 ? updating_frame
181 : XFRAME (selected_frame));
182 180
183 if (!NILP (Vring_bell_function)) 181 if (!NILP (Vring_bell_function))
184 { 182 {
@@ -206,10 +204,7 @@ ring_bell ()
206void 204void
207tty_ring_bell () 205tty_ring_bell ()
208{ 206{
209 struct frame *f = (updating_frame 207 struct frame *f = XFRAME (selected_frame);
210 ? updating_frame
211 : XFRAME (selected_frame));
212
213 struct tty_display_info *tty = FRAME_TTY (f); 208 struct tty_display_info *tty = FRAME_TTY (f);
214 209
215 OUTPUT (tty, (tty->TS_visible_bell && visible_bell 210 OUTPUT (tty, (tty->TS_visible_bell && visible_bell