Bug 640379

Summary: pipefail option causes intermittent failure of 'ls|! grep'
Product: Red Hat Enterprise Linux 5 Reporter: Jeff Bastian <jbastian>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: medium    
Version: 5.5CC: kvolny, mfranc, ovasik, spoyarek
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: ksh-20100621-1.el5 Doc Type: Bug Fix
Doc Text:
Previously, ksh did not always wait for a pipeline to complete when the pipefail option was used. Consequently, a failed exit status was erroneously reported even when the pipeline had not failed. With this update, the code has been improved and the pipefail option now functions as expected.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-21 05:50:06 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:    
Bug Blocks: 702016    
Attachments:
Description Flags
reproducer program
none
backported ksh patch
none
patch to fix this none

Description Jeff Bastian 2010-10-05 17:11:51 UTC
Created attachment 451728 [details]
reproducer program

Description of problem:
The ksh pipefail option does not wait for the pipeline to complete and can incorrectly report a failed exit status for a command like
   ls -l /bin/ksh | ! grep -e junk

Version-Release number of selected component (if applicable):
ksh-20100202-1.el5_5.1

How reproducible:
every time

Steps to Reproduce:
1. download and run the attached pipefail.ksh script
  
Actual results:
within approximately 1000 iterations of the loop, it will fail:
 ...
 running 367
 running 368
 running 369
The script executed for 2.926 seconds while looping 370 times before failing.

Expected results:
never fail

Additional info:

Comment 1 Jeff Bastian 2010-10-05 17:15:02 UTC
Created attachment 451732 [details]
backported ksh patch

Siddhesh Poyarekar narrowed down the upstream changes between 20100811 and 20100924 found this patch solves the problem.

Comment 3 Michal Hlavinka 2010-10-06 12:39:52 UTC
reproducible with 20100202

Comment 4 RHEL Program Management 2011-01-11 21:09:36 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 5 RHEL Program Management 2011-01-11 22:44:48 UTC
This request was erroneously denied for the current release of
Red Hat Enterprise Linux.  The error has been fixed and this
request has been re-proposed for the current release.

Comment 8 Michal Hlavinka 2011-03-14 12:22:08 UTC
Comment on attachment 451732 [details]
backported ksh patch

this patch does not work, it's causing regressions:

test basic.sh begins at 2011-03-14+13:20:37
        basic.sh[477]: pipefail causing /bin/true to wait for other end of pipe
test basic.sh failed at 2011-03-14+13:21:02 with exit code 1 [ 95 tests 1 error ]

Comment 10 Michal Hlavinka 2011-03-14 12:48:20 UTC
Created attachment 484163 [details]
patch to fix this

not that different, I know, just one section missing. Despite we did not used it in version for which last patch was prepared, we need it now.

Comment 12 RHEL Program Management 2011-05-31 13:45:07 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 15 Michal Hlavinka 2012-01-18 15:30:24 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Previously, ksh did not always wait for a pipeline to complete when the pipefail option was used. Consequently, a failed exit status was erroneously reported even when the pipeline had not failed. With this update, the code has been improved and the pipefail option now functions as expected.

Comment 16 errata-xmlrpc 2012-02-21 05:50:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0159.html