Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 3 product line. The current stable release is 3.9. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 128274

Summary: bash reports "broken pipe" erroneously
Product: Red Hat Enterprise Linux 3 Reporter: Alan Sparks <asparks>
Component: bashAssignee: Tomas Janousek <tjanouse>
Status: CLOSED WONTFIX QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: cward, twaugh
Target Milestone: ---Keywords: Regression, Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: 2.05b-44 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-12-20 16:08:11 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:
Attachments:
Description Flags
test data
none
Requested strace output none

Description Alan Sparks 2004-07-21 01:06:53 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7)
Gecko/20040626 Firefox/0.8 StumbleUpon/1.904

Description of problem:
bash pipes fail apparently if close to 4096 bytes of data flows
through the pipe.  Or something like that.  Random 'broken pipe'
messages occur if the following procedure is followed.



Version-Release number of selected component (if applicable):
bash-2.05b-29

How reproducible:
Always

Steps to Reproduce:
1. Use the attached data file (mq.txt).
2. create an executable script (foo.sh) with the following:

cat mq.txt | head -922 \
        | perl -n -e '/^\s+\<.*\@(.*)\>/ && print "$1\n"' \
        | sort \
        | uniq -c \
        | sort -nr

3. Run script.  Note a few lines, no errors.
4.Vary the number in the first "head" to -923 and -924, rerun program.
 You will note that with -923 up, you will sporadically get "broken
pipe" messages from the shell.

    

Actual Results:  $ ./foo.sh |head
      5 hotamil.com
      4 hotmail.
      4 belsouth.net
      4 aol.comy
      3 verison.net
      2 yahoo.comm
      2 yahoo.
      2 us.army.mail
      2 pipersoftware.net
      2 earhtlink.net
./foo.sh: line 5:  2252 Broken pipe             cat mq.txt
      2253 Done                    | head -925
      2254 Done                    | perl -n -e '/^\s+\<.*\@(.*)\>/ &&
print "$1\n"'
      2255 Done                    | sort
      2256 Done                    | uniq -c
      2257                       | sort -nr

Expected Results:  $ ./foo.sh |head
      5 hotamil.com
      4 hotmail.
      4 belsouth.net
      4 aol.comy
      3 verison.net
      2 yahoo.comm
      2 yahoo.
      2 us.army.mail
      2 pipersoftware.net
      2 earhtlink.net
[asparks@stampy asparks]$

Additional info:

Comment 1 Alan Sparks 2004-07-21 01:08:57 UTC
Created attachment 102092 [details]
test data

Comment 2 Tim Waugh 2004-07-21 13:47:34 UTC
Please attach the output of 'strace -f bash ./foo.sh >/dev/null' for a
run that gives a broken pipe error.

Comment 3 Alan Sparks 2004-07-21 15:38:59 UTC
Created attachment 102108 [details]
Requested strace output

This is tweaky, since the main failure mode is when the foo.sh output is
redirected into a program that may terminate early (thus creating the potential
"broken pipe" circumstance.  I've run the command:
(strace -f bash ./foo.sh |head) >trace.out 2>&1
and included a run that shows the broken pipe output.  I note that the same
sporadic behavior occurs here too, sometimes the run will NOT throw a sigpipe.

Comment 4 Tim Waugh 2004-07-21 16:55:10 UTC
Here is a simpler test case:

echo 'for x in $(seq 1 2500); do echo $x; done' > test1.sh
echo 'for x in $(seq 1 2500); do echo $x; done | cat' > test2.sh
bash ./test1.sh | head -n 1 # no error
bash ./test2.sh | head -n 1 # broken pipe

This behaviour is configurable, and I have disabled SIGPIPE error
reporting in Fedora development.  This change will appear in a future
release of Red Hat Enterprise Linux.

Comment 9 Chris Ward 2007-12-12 15:52:42 UTC
When running the given test case, 

echo 'for x in $(seq 1 2500); do echo $x; done' > test1.sh
echo 'for x in $(seq 1 2500); do echo $x; done | cat' > test2.sh
bash ./test1.sh | head -n 1 # no error
bash ./test2.sh | head -n 1 # broken pipe

Bash still returns error about a broken pipe.

%> rpm -q bash 
bash-2.05b-41.7.i386

%> rpm -q --whatprovides /etc/redhat-release 
redhat-release-3AS-13.9.5.i386

RHTS available, /CoreOS/bash/builtins/broken-pipe-bz128274

Comment 10 Tomas Janousek 2007-12-20 16:08:11 UTC
The fix for this has never been committed to RHEL-3. Therefore, it's not a
regression and there's no way we can convince PM to let us fix it (not that I
consider that worthwhile).