Bug 56166

Summary: /usr/bin/script exits prematurely if STDIN is closed
Product: Base System Reporter: Colin Percival <cperciva>
Component: binAssignee: Colin Percival <cperciva>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
script.diff none

Description Colin Percival 2003-08-30 01:30:07 UTC
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#
Comment 1 colin.percival 2003-10-10 20:12:50 UTC
See also bin/57414.

Colin Percival
Comment 2 colin.percival 2003-10-16 20:32:23 UTC
Improved patch:

--- script.diff begins here ---
--- script.c.orig	Thu Jul 20 11:35:21 2000
+++ script.c	Thu Oct 16 20:25:20 2003
@@ -162,7 +162,8 @@
  	FD_ZERO(&rfd);
  	for (;;) {
  		FD_SET(master, &rfd);
-		FD_SET(STDIN_FILENO, &rfd);
+		if (argv[0] == NULL)
+			FD_SET(STDIN_FILENO, &rfd);
  		if (flushtime > 0) {
  			tv.tv_sec = flushtime;
  			tv.tv_usec = 0;
--- script.diff ends here ---
Comment 3 Colin Percival freebsd_committer freebsd_triage 2004-01-22 21:07:11 UTC
State Changed
From-To: open->patched

Fixed in -current, will MFC in 7 days. 
Claim ownership to remind myself to close this later. 



Comment 4 Colin Percival freebsd_committer freebsd_triage 2004-01-22 21:07:11 UTC
Responsible Changed
From-To: freebsd-bugs->cperciva

Fixed in -current, will MFC in 7 days. 
Claim ownership to remind myself to close this later.
Comment 5 Colin Percival freebsd_committer freebsd_triage 2004-03-13 09:24:07 UTC
State Changed
From-To: patched->closed

MFC to RELENG_4 is done.