summaryrefslogtreecommitdiffstats
path: root/usr.bin/script
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2004-02-15 17:30:13 +0000
committercperciva <cperciva@FreeBSD.org>2004-02-15 17:30:13 +0000
commite2c5d659cc6c9906592b232f96d8bebdc5f9966a (patch)
tree4ce8c64fd19756fb195c1ad97da43d433878f6c0 /usr.bin/script
parentd2e6533b8db9cf22286d5c119a6aa68dec8f0b1b (diff)
downloadFreeBSD-src-e2c5d659cc6c9906592b232f96d8bebdc5f9966a.zip
FreeBSD-src-e2c5d659cc6c9906592b232f96d8bebdc5f9966a.tar.gz
Attempt #2 to fix script(1) if the standard input is closed: If we
read EOF from STDIN_FILENO, write zero bytes into the pseudo-terminal; this is interpreted as an EOF by the program being scripted. I've tested this with two non-interactive scripts: # echo 5 | script foo sh -c 'read x; sleep $x; echo bar' # echo bar | xargs script foo echo and one interactive program: # script foo more /etc/passwd and everything seems to work properly... PR: bin/56166, bin/57414, ports/57415, ports/60534 Approved by: rwatson (mentor) MFC after: 2 weeks
Diffstat (limited to 'usr.bin/script')
-rw-r--r--usr.bin/script/script.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index 48f026b..ad706dc 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -178,8 +178,10 @@ main(int argc, char *argv[])
break;
if (n > 0 && FD_ISSET(STDIN_FILENO, &rfd)) {
cc = read(STDIN_FILENO, ibuf, BUFSIZ);
- if (cc <= 0)
+ if (cc < 0)
break;
+ if (cc == 0)
+ (void)write(master, ibuf, 0);
if (cc > 0) {
(void)write(master, ibuf, cc);
if (kflg && tcgetattr(master, &stt) >= 0 &&
OpenPOWER on IntegriCloud