diff options
| author | Karoly Lorentey | 2004-01-11 02:45:44 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-01-11 02:45:44 +0000 |
| commit | 4ca927b4e0eb688a0eb224463288443164dd716f (patch) | |
| tree | 07e786aa4aba5640b38a872163b8960c86368d92 | |
| parent | 8f1ce42333b410e736053a7c5cbbf102032c84f2 (diff) | |
| download | emacs-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
| -rw-r--r-- | README.multi-tty | 38 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 6 | ||||
| -rw-r--r-- | src/keyboard.c | 37 | ||||
| -rw-r--r-- | src/sysdep.c | 33 | ||||
| -rw-r--r-- | src/term.c | 9 |
5 files changed, 85 insertions, 38 deletions
diff --git a/README.multi-tty b/README.multi-tty index e7979661831..8ca1c10a2ed 100644 --- a/README.multi-tty +++ b/README.multi-tty | |||
| @@ -133,14 +133,12 @@ THINGS TO DO | |||
| 133 | the fly in write_glyphs, which might be problematic, as color | 133 | the fly in write_glyphs, which might be problematic, as color |
| 134 | approximation is currently done in lisp (term/tty-colors.el).) | 134 | approximation is currently done in lisp (term/tty-colors.el).) |
| 135 | 135 | ||
| 136 | ** frame-creation-function should always create a frame that is on the | ||
| 137 | same display as the selected frame. Maybe frame-creation-function | ||
| 138 | should simply be removed and make-frame changed to do the right | ||
| 139 | thing. | ||
| 140 | |||
| 141 | ** Fix interactive use of temacs. There are face-related SEGVs, most | 136 | ** Fix interactive use of temacs. There are face-related SEGVs, most |
| 142 | likely because of changes in realize_default_face, realize_face. | 137 | likely because of changes in realize_default_face, realize_face. |
| 143 | 138 | ||
| 139 | ** Very strange bug: visible-bell does not work on secondary | ||
| 140 | terminals. This might be something xterm (konsole) specific. | ||
| 141 | |||
| 144 | ** Allow opening an X session after -nw. | 142 | ** Allow opening an X session after -nw. |
| 145 | 143 | ||
| 146 | ** Find out the best way to support suspending Emacs with multiple | 144 | ** Find out the best way to support suspending Emacs with multiple |
| @@ -149,7 +147,7 @@ THINGS TO DO | |||
| 149 | extend emacsclient to handle suspend/resume. A `kill -STOP' almost | 147 | extend emacsclient to handle suspend/resume. A `kill -STOP' almost |
| 150 | works right now.) | 148 | works right now.) |
| 151 | 149 | ||
| 152 | ** Exiting Emacs while there are emacsclient frames don't restore the | 150 | ** Exiting Emacs while there are emacsclient frames doesn't restore the |
| 153 | ttys to their default states. | 151 | ttys to their default states. |
| 154 | 152 | ||
| 155 | ** Move baud_rate to struct display. | 153 | ** Move baud_rate to struct display. |
| @@ -182,9 +180,6 @@ THINGS TO DO | |||
| 182 | why raw terminal support is broken again. I really do need to | 180 | why raw terminal support is broken again. I really do need to |
| 183 | understand input.) | 181 | understand input.) |
| 184 | 182 | ||
| 185 | ** Make sure C-g goes to the right frame with ttys. This is hard, as | ||
| 186 | SIGINT doesn't have a tty parameter. :-( | ||
| 187 | |||
| 188 | ** I have seen a case when Emacs with multiple ttys fell into a loop | 183 | ** I have seen a case when Emacs with multiple ttys fell into a loop |
| 189 | eating 100% of CPU time. Strace showed this loop: | 184 | eating 100% of CPU time. Strace showed this loop: |
| 190 | 185 | ||
| @@ -212,7 +207,8 @@ THINGS TO DO | |||
| 212 | about face problems. This can even lock up Emacs (if the recursive | 207 | about face problems. This can even lock up Emacs (if the recursive |
| 213 | frame sets single_kboard). Update: the face problems are caused by | 208 | frame sets single_kboard). Update: the face problems are caused by |
| 214 | bugs in term.el, not in multi-tty. The lockup is caused by | 209 | bugs in term.el, not in multi-tty. The lockup is caused by |
| 215 | single_kboard mode. | 210 | single_kboard mode, and is not easily solvable. The best thing to |
| 211 | do is to simply refuse to create a tty frame of type `eterm'. | ||
| 216 | 212 | ||
| 217 | DIARY OF CHANGES | 213 | DIARY OF CHANGES |
| 218 | ---------------- | 214 | ---------------- |
| @@ -520,4 +516,26 @@ DIARY OF CHANGES | |||
| 520 | 516 | ||
| 521 | (Fixed.) | 517 | (Fixed.) |
| 522 | 518 | ||
| 519 | -- frame-creation-function should always create a frame that is on the | ||
| 520 | same display as the selected frame. Maybe frame-creation-function | ||
| 521 | should simply be removed and make-frame changed to do the right | ||
| 522 | thing. | ||
| 523 | |||
| 524 | (Done, with a nice hack. frame-creation-function is now frame-local.) | ||
| 525 | |||
| 526 | -- Fix C-g on raw ttys. | ||
| 527 | |||
| 528 | (Done. I disabled the interrupt/quit keys on all secondary | ||
| 529 | terminals, so Emacs sees C-g as normal input. This looks like an | ||
| 530 | overkill, because emacsclient has extra code to pass SIGINT to | ||
| 531 | Emacs, so C-g should remain the interrupt/quit key on emacsclient | ||
| 532 | frames. See the next entry why implementing this distinction would | ||
| 533 | be a bad idea.) | ||
| 534 | |||
| 535 | -- Make sure C-g goes to the right frame with ttys. This is hard, as | ||
| 536 | SIGINT doesn't have a tty parameter. :-( | ||
| 537 | |||
| 538 | (Done, the previous change fixes this as a pleasant side effect.) | ||
| 539 | |||
| 540 | |||
| 523 | ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d | 541 | ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d |
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 356784ae45c..cfbf73a20c7 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -299,8 +299,14 @@ init_signals (void) | |||
| 299 | { | 299 | { |
| 300 | /* Set up signal handlers. */ | 300 | /* Set up signal handlers. */ |
| 301 | signal (SIGWINCH, pass_signal_to_emacs); | 301 | signal (SIGWINCH, pass_signal_to_emacs); |
| 302 | |||
| 303 | /* Don't pass SIGINT and SIGQUIT to Emacs, because it has no way of | ||
| 304 | deciding which terminal the signal came from. C-g is now a | ||
| 305 | normal input event on secondary terminals. */ | ||
| 306 | #if 0 | ||
| 302 | signal (SIGINT, pass_signal_to_emacs); | 307 | signal (SIGINT, pass_signal_to_emacs); |
| 303 | signal (SIGQUIT, pass_signal_to_emacs); | 308 | signal (SIGQUIT, pass_signal_to_emacs); |
| 309 | #endif | ||
| 304 | } | 310 | } |
| 305 | 311 | ||
| 306 | 312 | ||
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 (); | |||
| 176 | void | 176 | void |
| 177 | ring_bell () | 177 | ring_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 () | |||
| 206 | void | 204 | void |
| 207 | tty_ring_bell () | 205 | tty_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 |