summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2011-10-15 19:08:22 +0000
committertrociny <trociny@FreeBSD.org>2011-10-15 19:08:22 +0000
commit5edcf5899db7cc6cdce03abaa26bda3fadf4548a (patch)
tree1e1f6ecd10cf7a74d4aaef9b1144ec2a7bd197dc
parent5bfe25432f47fc51db50d501a15474b6dadf73af (diff)
downloadFreeBSD-src-5edcf5899db7cc6cdce03abaa26bda3fadf4548a.zip
FreeBSD-src-5edcf5899db7cc6cdce03abaa26bda3fadf4548a.tar.gz
In r225809 the intention was to send VEOF only once if STDIN was not a
terminal. Unfortunately the fix was incorrect and for flushtime > 0 it keept sending VEOF. Sent VEOF generates ^D\b\b echoed by the terminal, which was reported in bin/161526. Note, we still send VEOF at least once. Otherwise commands like below would hang forever: echo 1 |script /tmp/script.out cat PR: bin/161526 Reported by: Adrian Wontroba <aw1@stade.co.uk>, Stefan Bethke <stb@lassitu.de> Tested by: Stefan Bethke <stb@lassitu.de> MFC after: 3 days
-rw-r--r--usr.bin/script/script.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index ea5a1f6..cd577f7 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -163,12 +163,15 @@ main(int argc, char *argv[])
FD_SET(master, &rfd);
if (readstdin)
FD_SET(STDIN_FILENO, &rfd);
- if ((!readstdin && ttyflg) || flushtime > 0) {
- tv.tv_sec = !readstdin && ttyflg ? 1 :
- flushtime - (tvec - start);
+ if (!readstdin && ttyflg) {
+ tv.tv_sec = 1;
tv.tv_usec = 0;
tvp = &tv;
readstdin = 1;
+ } else if (flushtime > 0) {
+ tv.tv_sec = flushtime - (tvec - start);
+ tv.tv_usec = 0;
+ tvp = &tv;
} else {
tvp = NULL;
}
OpenPOWER on IntegriCloud