diff options
Diffstat (limited to 'src/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 93 |
1 files changed, 22 insertions, 71 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 0c04d95304c..a86e7c5f8e4 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -169,9 +169,6 @@ struct kboard *echo_kboard; | |||
| 169 | 169 | ||
| 170 | Lisp_Object echo_message_buffer; | 170 | Lisp_Object echo_message_buffer; |
| 171 | 171 | ||
| 172 | /* True means C-g should cause immediate error-signal. */ | ||
| 173 | bool immediate_quit; | ||
| 174 | |||
| 175 | /* Character that causes a quit. Normally C-g. | 172 | /* Character that causes a quit. Normally C-g. |
| 176 | 173 | ||
| 177 | If we are running on an ordinary terminal, this must be an ordinary | 174 | If we are running on an ordinary terminal, this must be an ordinary |
| @@ -3584,16 +3581,7 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event, | |||
| 3584 | as input, set quit-flag to cause an interrupt. */ | 3581 | as input, set quit-flag to cause an interrupt. */ |
| 3585 | if (!NILP (Vthrow_on_input) | 3582 | if (!NILP (Vthrow_on_input) |
| 3586 | && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events))) | 3583 | && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events))) |
| 3587 | { | 3584 | Vquit_flag = Vthrow_on_input; |
| 3588 | Vquit_flag = Vthrow_on_input; | ||
| 3589 | /* If we're inside a function that wants immediate quits, | ||
| 3590 | do it now. */ | ||
| 3591 | if (immediate_quit && NILP (Vinhibit_quit)) | ||
| 3592 | { | ||
| 3593 | immediate_quit = false; | ||
| 3594 | maybe_quit (); | ||
| 3595 | } | ||
| 3596 | } | ||
| 3597 | } | 3585 | } |
| 3598 | 3586 | ||
| 3599 | 3587 | ||
| @@ -7053,40 +7041,22 @@ tty_read_avail_input (struct terminal *terminal, | |||
| 7053 | 7041 | ||
| 7054 | /* Now read; for one reason or another, this will not block. | 7042 | /* Now read; for one reason or another, this will not block. |
| 7055 | NREAD is set to the number of chars read. */ | 7043 | NREAD is set to the number of chars read. */ |
| 7056 | do | 7044 | nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); |
| 7057 | { | 7045 | /* POSIX infers that processes which are not in the session leader's |
| 7058 | nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); | 7046 | process group won't get SIGHUPs at logout time. BSDI adheres to |
| 7059 | /* POSIX infers that processes which are not in the session leader's | 7047 | this part standard and returns -1 from read (0) with errno==EIO |
| 7060 | process group won't get SIGHUPs at logout time. BSDI adheres to | 7048 | when the control tty is taken away. |
| 7061 | this part standard and returns -1 from read (0) with errno==EIO | 7049 | Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ |
| 7062 | when the control tty is taken away. | 7050 | if (nread == -1 && errno == EIO) |
| 7063 | Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ | 7051 | return -2; /* Close this terminal. */ |
| 7064 | if (nread == -1 && errno == EIO) | 7052 | #if defined AIX && defined _BSD |
| 7065 | return -2; /* Close this terminal. */ | 7053 | /* The kernel sometimes fails to deliver SIGHUP for ptys. |
| 7066 | #if defined (AIX) && defined (_BSD) | 7054 | This looks incorrect, but it isn't, because _BSD causes |
| 7067 | /* The kernel sometimes fails to deliver SIGHUP for ptys. | 7055 | O_NDELAY to be defined in fcntl.h as O_NONBLOCK, |
| 7068 | This looks incorrect, but it isn't, because _BSD causes | 7056 | and that causes a value other than 0 when there is no input. */ |
| 7069 | O_NDELAY to be defined in fcntl.h as O_NONBLOCK, | 7057 | if (nread == 0) |
| 7070 | and that causes a value other than 0 when there is no input. */ | 7058 | return -2; /* Close this terminal. */ |
| 7071 | if (nread == 0) | ||
| 7072 | return -2; /* Close this terminal. */ | ||
| 7073 | #endif | ||
| 7074 | } | ||
| 7075 | while ( | ||
| 7076 | /* We used to retry the read if it was interrupted. | ||
| 7077 | But this does the wrong thing when O_NONBLOCK causes | ||
| 7078 | an EAGAIN error. Does anybody know of a situation | ||
| 7079 | where a retry is actually needed? */ | ||
| 7080 | #if 0 | ||
| 7081 | nread < 0 && (errno == EAGAIN || errno == EFAULT | ||
| 7082 | #ifdef EBADSLT | ||
| 7083 | || errno == EBADSLT | ||
| 7084 | #endif | ||
| 7085 | ) | ||
| 7086 | #else | ||
| 7087 | 0 | ||
| 7088 | #endif | 7059 | #endif |
| 7089 | ); | ||
| 7090 | 7060 | ||
| 7091 | #ifndef USABLE_FIONREAD | 7061 | #ifndef USABLE_FIONREAD |
| 7092 | #if defined (USG) || defined (CYGWIN) | 7062 | #if defined (USG) || defined (CYGWIN) |
| @@ -10445,30 +10415,12 @@ handle_interrupt (bool in_signal_handler) | |||
| 10445 | } | 10415 | } |
| 10446 | else | 10416 | else |
| 10447 | { | 10417 | { |
| 10448 | /* If executing a function that wants to be interrupted out of | 10418 | /* Request quit when it's safe. */ |
| 10449 | and the user has not deferred quitting by binding `inhibit-quit' | 10419 | int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1; |
| 10450 | then quit right away. */ | 10420 | force_quit_count = count; |
| 10451 | if (immediate_quit && NILP (Vinhibit_quit) && !waiting_for_input) | 10421 | if (count == 3) |
| 10452 | { | 10422 | Vinhibit_quit = Qnil; |
| 10453 | struct gl_state_s saved; | 10423 | Vquit_flag = Qt; |
| 10454 | |||
| 10455 | immediate_quit = false; | ||
| 10456 | pthread_sigmask (SIG_SETMASK, &empty_mask, 0); | ||
| 10457 | saved = gl_state; | ||
| 10458 | quit (); | ||
| 10459 | gl_state = saved; | ||
| 10460 | } | ||
| 10461 | else | ||
| 10462 | { /* Else request quit when it's safe. */ | ||
| 10463 | int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1; | ||
| 10464 | force_quit_count = count; | ||
| 10465 | if (count == 3) | ||
| 10466 | { | ||
| 10467 | immediate_quit = true; | ||
| 10468 | Vinhibit_quit = Qnil; | ||
| 10469 | } | ||
| 10470 | Vquit_flag = Qt; | ||
| 10471 | } | ||
| 10472 | } | 10424 | } |
| 10473 | 10425 | ||
| 10474 | pthread_sigmask (SIG_SETMASK, &empty_mask, 0); | 10426 | pthread_sigmask (SIG_SETMASK, &empty_mask, 0); |
| @@ -10907,7 +10859,6 @@ init_keyboard (void) | |||
| 10907 | { | 10859 | { |
| 10908 | /* This is correct before outermost invocation of the editor loop. */ | 10860 | /* This is correct before outermost invocation of the editor loop. */ |
| 10909 | command_loop_level = -1; | 10861 | command_loop_level = -1; |
| 10910 | immediate_quit = false; | ||
| 10911 | quit_char = Ctl ('g'); | 10862 | quit_char = Ctl ('g'); |
| 10912 | Vunread_command_events = Qnil; | 10863 | Vunread_command_events = Qnil; |
| 10913 | timer_idleness_start_time = invalid_timespec (); | 10864 | timer_idleness_start_time = invalid_timespec (); |