Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jul 2002 13:04:42 +0200 (MEST)
From:      Moritz Willers <willers@rumori.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/40334: closing of file desriptors broken in /bin/sh
Message-ID:  <200207081104.g68B4gR68945@rumori.com>

next in thread | raw e-mail | index | archive | help

>Number:         40334
>Category:       bin
>Synopsis:       closing of file desriptors broken in /bin/sh
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 08 04:10:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Moritz Willers
>Release:        FreeBSD 4.6-RELEASE-p1 i386
>Organization:
>Environment:
System: FreeBSD sand.wit.ch 4.6-RELEASE-p1 FreeBSD 4.6-RELEASE-p1


>Description:
	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

>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)


>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
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207081104.g68B4gR68945>