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:
@ -1122,7 +1122,7 @@ static int readit(void) // read (maybe cursor) key from stdin
|
||||
// on nonblocking stdin.
|
||||
// Note: read_key sets errno to 0 on success.
|
||||
again:
|
||||
c = read_key(STDIN_FILENO, readbuffer, /*timeout:*/ -1);
|
||||
c = safe_read_key(STDIN_FILENO, readbuffer, /*timeout:*/ -1);
|
||||
if (c == -1) { // EOF/error
|
||||
if (errno == EAGAIN) // paranoia
|
||||
goto again;
|
||||
@ -4770,7 +4770,7 @@ static void edit_file(char *fn)
|
||||
uint64_t k;
|
||||
write1(ESC"[999;999H" ESC"[6n");
|
||||
fflush_all();
|
||||
k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100);
|
||||
k = safe_read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100);
|
||||
if ((int32_t)k == KEYCODE_CURSOR_POS) {
|
||||
uint32_t rc = (k >> 32);
|
||||
columns = (rc & 0x7fff);
|
||||
|
Reference in New Issue
Block a user