Bug 40334 - closing of file desriptors broken in /bin/sh
Summary: closing of file desriptors broken in /bin/sh
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.6-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Tim Robbins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-08 12:10 UTC by Moritz Willers
Modified: 2002-07-20 05:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Moritz Willers 2002-07-08 12:10:01 UTC
	closing file desriptors via ">&-" in /bin/sh does not work.
	it seems the commits to redir.c going to 4.6 caused this.

	http://www.freebsd.org/cgi/cvsweb.cgi/src/bin/sh/redir.c.diff?r1=1.12.2.1&r2=1.12.2.2

Fix: 

I did reinsert the close(fd); in line 148 in redir.c which fixed
	the problem, but I do not understand the code in redir.c really,
	so I have no idea about any side effects this could have.

 			if (!try) {
 				sv->renamed[fd] = i;
+				close(fd);
 			}


thanks - Moritz
How-To-Repeat: 	the below command should produce *no* output:

	# uname -r
	4.6-RELEASE-p1
	# /bin/sh -c 'echo "ha" >&-'
	ha
	#

	from the manpage:

            [n]>&-        close stdout (or file descriptor n)
Comment 1 Tim Robbins freebsd_committer freebsd_triage 2002-07-08 16:16:10 UTC
Responsible Changed
From-To: freebsd-bugs->tjr

I am working on a patch for this.
Comment 2 Tim Robbins freebsd_committer freebsd_triage 2002-07-09 09:56:01 UTC
State Changed
From-To: open->patched

Fix committed to -CURRENT, I will MFC it after a week.
Comment 3 Tim Robbins freebsd_committer freebsd_triage 2002-07-20 05:15:03 UTC
State Changed
From-To: patched->closed

Change has been MFC'd.