ash,hush: fix handling of SIGINT while waiting for interactive input

function                                             old     new   delta
lineedit_read_key                                    160     237     +77
__pgetc                                              522     589     +67
fgetc_interactive                                    244     309     +65
safe_read_key                                          -      39     +39
read_key                                             588     607     +19
record_pending_signo                                  23      32      +9
signal_handler                                        75      81      +6
.rodata                                           104312  104309      -3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 6/1 up/down: 282/-3)            Total: 279 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2022-01-17 03:02:40 +01:00
parent a277506a64
commit 12566e7f9b
9 changed files with 122 additions and 41 deletions

View File

@ -1137,9 +1137,9 @@ static int64_t getch_nowait(void)
#endif
}
/* We have kbd_fd in O_NONBLOCK mode, read inside read_key()
/* We have kbd_fd in O_NONBLOCK mode, read inside safe_read_key()
* would not block even if there is no input available */
key64 = read_key(kbd_fd, kbd_input, /*timeout off:*/ -2);
key64 = safe_read_key(kbd_fd, kbd_input, /*timeout off:*/ -2);
if ((int)key64 == -1) {
if (errno == EAGAIN) {
/* No keyboard input available. Since poll() did return,