diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-05-02 20:39:02 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-05-02 20:39:02 +0200 |
commit | 0cc9b1843df8c4b6838446542b3f7d5780fb9e84 (patch) | |
tree | ce983d93b2fa364861887c23f47e873a933d6889 | |
parent | a1a3b595e1c96c3568818d019864bb23cd33e673 (diff) | |
download | busybox-w32-0cc9b1843df8c4b6838446542b3f7d5780fb9e84.tar.gz busybox-w32-0cc9b1843df8c4b6838446542b3f7d5780fb9e84.tar.bz2 busybox-w32-0cc9b1843df8c4b6838446542b3f7d5780fb9e84.zip |
vi: survive if stdin is nonblocking. closes 9851
function old new delta
readit 55 69 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/editors/vi.c b/editors/vi.c index f33db66c6..76d1f261b 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -2816,8 +2816,15 @@ static int readit(void) // read (maybe cursor) key from stdin | |||
2816 | int c; | 2816 | int c; |
2817 | 2817 | ||
2818 | fflush_all(); | 2818 | fflush_all(); |
2819 | c = read_key(STDIN_FILENO, readbuffer, /*timeout off:*/ -2); | 2819 | |
2820 | // Wait for input. TIMEOUT = -1 makes read_key wait even | ||
2821 | // on nonblocking stdin. | ||
2822 | // Note: read_key sets errno to 0 on success. | ||
2823 | again: | ||
2824 | c = read_key(STDIN_FILENO, readbuffer, /*timeout:*/ -1); | ||
2820 | if (c == -1) { // EOF/error | 2825 | if (c == -1) { // EOF/error |
2826 | if (errno == EAGAIN) // paranoia | ||
2827 | goto again; | ||
2821 | go_bottom_and_clear_to_eol(); | 2828 | go_bottom_and_clear_to_eol(); |
2822 | cookmode(); // terminal to "cooked" | 2829 | cookmode(); // terminal to "cooked" |
2823 | bb_error_msg_and_die("can't read user input"); | 2830 | bb_error_msg_and_die("can't read user input"); |