bin/56166: /usr/bin/script exits prematurely if STDIN is closed
Colin Percival
cperciva at daemonology.net
Fri Aug 29 17:30:09 PDT 2003
>Number: 56166
>Category: bin
>Synopsis: /usr/bin/script exits prematurely if STDIN is closed
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Aug 29 17:30:07 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Colin Percival
>Release: FreeBSD 4.7-SECURITY i386
>Organization:
>Environment:
System: FreeBSD beastie.daemonology.net 4.7-SECURITY FreeBSD 4.7-SECURITY #0: Tue Aug 12 16:54:33 GMT 2003 root at builder.daemonology.net:/usr/obj/usr/src/sys/GENERICMP i386
>Description:
If the standard input is closed, /usr/bin/script will exit immediately.
This behaviour is sensible if script is being used interactively (to log a
shell session) but not sensible otherwise (eg, if script is being used to
log the output of a program).
>How-To-Repeat:
beastie# script -q /dev/null echo hello world
hello world
beastie# echo "hello world" | xargs script -q /dev/null echo
beastie#
>Fix:
--- script.diff begins here ---
--- usr.bin/script.c.orig Thu Jul 20 11:35:21 2000
+++ usr.bin/script.c Sat Aug 30 00:58:04 2003
@@ -170,7 +170,7 @@
n = select(master + 1, &rfd, 0, 0, tvp);
if (n < 0 && errno != EINTR)
break;
- if (n > 0 && FD_ISSET(STDIN_FILENO, &rfd)) {
+ if (! argv[0] && n > 0 && FD_ISSET(STDIN_FILENO, &rfd)) {
cc = read(STDIN_FILENO, ibuf, BUFSIZ);
if (cc <= 0)
break;
--- script.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list