summaryrefslogtreecommitdiffstats
path: root/usr.bin/more
diff options
context:
space:
mode:
authorhoek <hoek@FreeBSD.org>2000-05-12 04:04:27 +0000
committerhoek <hoek@FreeBSD.org>2000-05-12 04:04:27 +0000
commit37a80cf698ee8cf049e405ad08e926b4dca3979e (patch)
tree5a2ba0e41b0bcf350e0e58b339ffd73bb475dcb8 /usr.bin/more
parentd2117fd239136fa13acb19f0351585c577c7ac20 (diff)
downloadFreeBSD-src-37a80cf698ee8cf049e405ad08e926b4dca3979e.zip
FreeBSD-src-37a80cf698ee8cf049e405ad08e926b4dca3979e.tar.gz
Improve hack from previous commit to this file: exit if we get successive
EOFs from reading stderr (eg. not from argv[1]).
Diffstat (limited to 'usr.bin/more')
-rw-r--r--usr.bin/more/os.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/usr.bin/more/os.c b/usr.bin/more/os.c
index 9a0953b..5ae3b75 100644
--- a/usr.bin/more/os.c
+++ b/usr.bin/more/os.c
@@ -184,11 +184,21 @@ iread(fd, buf, len)
flush();
reading = 1;
n = read(fd, buf, len);
- /* There's really no terribly impressive reason why we should just
- * sighup after a single EOF read, nor is there any particular
- * reason why we SIGHUP ourselves rather than calling exit(). However,
- * none of it hurts, either. */
- if (n == 0) neofs++;
+ /*
+ * XXX This is a hack. We do want to exit if we read a couple EOFs
+ * from the terminal (to avoid spinning on input if the user
+ * leaves us hanging), but we should be comparing against the
+ * tty variable from ttyin.c.
+ *
+ * We wait for two successive EOFs just to give any potential
+ * oddities the benefit of the doubt.
+ */
+ if (fd == 2) {
+ if (n == 0)
+ neofs++;
+ else
+ neofs = 0;
+ }
if (neofs > 2) kill(getpid(), SIGHUP);
reading = 0;
OpenPOWER on IntegriCloud