Bug 757699 - A Pipe returns unexpected exit code.
Summary: A Pipe returns unexpected exit code.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: bash
Version: 6.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Roman Rakus
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-28 12:39 UTC by Dimitar Yordanov
Modified: 2014-01-13 00:14 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-11-30 13:33:20 UTC
Target Upstream Version:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.