From 5edcf5899db7cc6cdce03abaa26bda3fadf4548a Mon Sep 17 00:00:00 2001 From: trociny Date: Sat, 15 Oct 2011 19:08:22 +0000 Subject: 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 , Stefan Bethke Tested by: Stefan Bethke MFC after: 3 days --- usr.bin/script/script.c | 9 ++++++--- 1 file 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; } -- cgit v1.1