Bug 757699

Summary: A Pipe returns unexpected exit code.
Product: Red Hat Enterprise Linux 6 Reporter: Dimitar Yordanov <dyordano>
Component: bashAssignee: Roman Rakus <rrakus>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: prc, tsmetana
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-30 13:33:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Dimitar Yordanov 2011-11-28 12:39:44 UTC
Description of problem:

# set -o pipefail
# cat /var/log/messages  | head -n 111111>  /dev/null; echo $?
0
# cat /var/log/messages  | head -n 1>  /dev/null; echo $?
141

Version-Release number of selected component (if applicable):
coreutils-5.97-34.el5
coreutils-8.4-16.el6.x86_64

How reproducible:
100%


Steps to Reproduce:
1. set -o pipefail
2.cat /var/log/messages  | head -n 111111>  /dev/null; echo $?
3.cat /var/log/messages  | head -n 1>  /dev/null; echo $?
  
Actual results:
0
0

Expected results:
0
141

Additional info:

Comment 1 Roman Rakus 2011-11-28 14:44:59 UTC
Didn't you interchange Actual and Expected behaviour? Both cases (2 and 3) should return 0 exit codes.

Comment 2 Dimitar Yordanov 2011-11-28 14:55:12 UTC
(In reply to comment #1)
> Didn't you interchange Actual and Expected behaviour? Both cases (2 and 3)
> should return 0 exit codes.

Yes, you are absolutely correct.
Actual and Expected behavior are  interchanged.

Comment 3 Roman Rakus 2011-11-30 07:01:18 UTC
I can't reproduce it;

RHEL6:
[root@localhost ~]# rpm -q bash coreutils
bash-4.1.2-8.el6.x86_64
coreutils-8.4-13.el6.x86_64
[root@localhost ~]# set -o pipefail
[root@localhost ~]# cat /var/log/messages  | head -n 111111 >  /dev/null; echo $?
0
[root@localhost ~]# cat /var/log/messages  | head -n 1 >   /dev/null; echo $?
0


RHEL5:
[root@localhost ~]# rpm -q bash coreutils
bash-3.2-32.el5
coreutils-5.97-34.el5
[root@localhost ~]# set -o pipefail
[root@localhost ~]# cat /var/log/messages  | head -n 111111 >  /dev/null; echo $?
0
[root@localhost ~]# cat /var/log/messages  | head -n 1 >  /dev/null; echo $?
0