Bug 217394

Summary: bash does not close filehandles when asked.
Product: Red Hat Enterprise Linux 5 Reporter: Oleg Drokin <green>
Component: bashAssignee: Tomas Janousek <tjanouse>
Status: CLOSED ERRATA QA Contact: Chris Ward <cward>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.0CC: armbru, cward, roland.friedwagner
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2008-0380 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-05-21 15:35:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 380421    
Bug Blocks:    

Description Oleg Drokin 2006-11-27 18:49:42 UTC
Description of problem:

When I want to close a filehandle in current shell (exec NUM<&-), it suddenly
stopped to work with rhel5betas.
It worked just fine with rhel4 and with fedora core 2 & 3, stopped to work in
fc6 too.

How reproducible:

100% reproducible, this simple script demonstrates the issue:
exec 101< /etc/passwd ; ls -la /proc/$$/fd ; exec 101<&- ; ls -la /proc/$$/fd
On rhel5beta I get
total 5
dr-x------ 2 green green  0 Nov 27 20:44 .
dr-xr-xr-x 4 green green  0 Nov 27 20:44 ..
lrwx------ 1 green green 64 Nov 27 20:44 0 -> /dev/pts/22
lrwx------ 1 green green 64 Nov 27 20:44 1 -> /dev/pts/22
lr-x------ 1 green green 64 Nov 27 20:44 101 -> /etc/passwd
lrwx------ 1 green green 64 Nov 27 20:44 2 -> /dev/pts/22
lrwx------ 1 green green 64 Nov 27 20:44 255 -> /dev/pts/22
total 5
dr-x------ 2 green green  0 Nov 27 20:44 .
dr-xr-xr-x 4 green green  0 Nov 27 20:44 ..
lrwx------ 1 green green 64 Nov 27 20:44 0 -> /dev/pts/22
lrwx------ 1 green green 64 Nov 27 20:44 1 -> /dev/pts/22
lr-x------ 1 green green 64 Nov 27 20:44 101 -> /etc/passwd
lrwx------ 1 green green 64 Nov 27 20:44 2 -> /dev/pts/22
lrwx------ 1 green green 64 Nov 27 20:44 255 -> /dev/pts/22

Where correct output is this (note how /etc/passwd is not show in second ls
output) (this example is from fc2):
total 5
dr-x------  2 green green  0 Nov 27 17:12 .
dr-xr-xr-x  3 green green  0 Nov 27 17:12 ..
lrwx------  1 green green 64 Nov 27 20:38 0 -> /dev/pts/1
lrwx------  1 green green 64 Nov 27 20:38 1 -> /dev/pts/1
lr-x------  1 green green 64 Nov 27 20:38 101 -> /etc/passwd
lrwx------  1 green green 64 Nov 27 20:38 2 -> /dev/pts/1
lrwx------  1 green green 64 Nov 27 20:38 255 -> /dev/pts/1
total 4
dr-x------  2 green green  0 Nov 27 17:12 .
dr-xr-xr-x  3 green green  0 Nov 27 17:12 ..
lrwx------  1 green green 64 Nov 27 20:38 0 -> /dev/pts/1
lrwx------  1 green green 64 Nov 27 20:38 1 -> /dev/pts/1
lrwx------  1 green green 64 Nov 27 20:38 2 -> /dev/pts/1
lrwx------  1 green green 64 Nov 27 20:38 255 -> /dev/pts/1

Additional info:
This must be some generic bash bug, as SLES10 also has this problem.

Comment 1 Oleg Drokin 2006-12-04 18:52:02 UTC
This seems to be fixed in latest bash, at least this entry at
http://tiswww.tis.case.edu/~chet/bash/CHANGES eems to be related:

ii. Fixed a bug that could cause file descriptors > 10 to not be closed even
    when closed explicitly by a script.        

Comment 3 RHEL Program Management 2007-06-05 20:49:17 UTC
This request was evaluated by Red Hat Product Management for
inclusion in a Red Hat Enterprise Linux release.  Since this
bugzilla is in a component that is not approved for the current
release, it has been closed with resolution deferred.  You may
reopen this bugzilla for consideration in the next release.

Comment 5 RHEL Program Management 2007-10-16 04:08:01 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 6 Chris Ward 2007-10-29 16:11:37 UTC
Which versions of Bash does this bug effect?

Comment 7 Tomas Janousek 2007-10-29 16:17:40 UTC
Only 3.1, I think. Isn't this a duplicate of bug 345181?

Comment 8 Tomas Janousek 2007-10-29 16:18:30 UTC
(or the other way round, probably, I should've closed the other one)

Comment 9 Tomas Janousek 2007-10-29 16:35:44 UTC
*** Bug 345181 has been marked as a duplicate of this bug. ***

Comment 10 Roland Friedwagner 2007-11-14 08:22:02 UTC
The Bug description ist wrong.
Should be Product: Red Hat Enterprise Linux
Version: 5(.1)

On our site we have to rewrite Shell Scripts, 
which do not work anymore after upgrade from RHEL4.

A quick fix whould be very appreciated.

Kind Regards,
 Roland


Comment 11 Tomas Janousek 2007-11-14 08:46:04 UTC
I know, we're fixing this in EL 5.2.

Comment 16 errata-xmlrpc 2008-05-21 15:35:55 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2008-0380.html