aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Denis Vlasenko <vda.linux@googlemail.com>2008-10-31 03:04:55 +0000
committerGravatar Denis Vlasenko <vda.linux@googlemail.com>2008-10-31 03:04:55 +0000
commit64974793b9fe0921c43e604de747caf7d32f671c (patch)
tree7df226f3206f2c35378b6594d5dcf5376de4bc46
parent028eab61bc44f34f27a4fb5cae03b5b6460b024d (diff)
downloadbusybox-64974793b9fe0921c43e604de747caf7d32f671c.tar.gz
busybox-64974793b9fe0921c43e604de747caf7d32f671c.tar.bz2
less: fix newly-introduced case of less spinning forever
on pty's closed etc
-rw-r--r--miscutils/less.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index b5d225a12..6c793ad8b 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -853,12 +853,16 @@ static ssize_t getch_nowait(void)
/* We have kbd_fd in O_NONBLOCK mode, read inside read_key()
* would not block even if there is no input available */
rd = read_key(kbd_fd, NULL, input);
- if (rd == -1 && errno == EAGAIN) {
- /* No keyboard input available. Since poll() did return,
- * we should have input on stdin */
- read_lines();
- buffer_fill_and_print();
- goto again;
+ if (rd == -1) {
+ if (errno == EAGAIN) {
+ /* No keyboard input available. Since poll() did return,
+ * we should have input on stdin */
+ read_lines();
+ buffer_fill_and_print();
+ goto again;
+ }
+ /* EOF/error (ssh session got killed etc) */
+ less_exit(0);
}
set_tty_cooked();
return rd;