Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 104788

Summary: Strange "Broken pipe" from /sbin/service
Product: [Retired] Red Hat Linux Reporter: Michal Jaegermann <michal>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED CURRENTRELEASE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 9CC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: FC4 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-09-30 19:57:01 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:

Description Michal Jaegermann 2003-09-22 00:11:28 UTC
Description of problem:

There is some strange interaction between /sbin/service and grep.
Look at that:

# service syslog status | grep -q running
/sbin/service: line 65: 18907 Broken pipe             env -i LANG=$LANG
"${SERVICEDIR}/${SERVICE}" ${OPTIONS}

OTOH doing that "directly"

#  /etc/init.d/syslog status | grep -q running && echo ok

prints an expected 'ok'.  Also dropping something else into a pipe, like

# service syslog status | cat | grep -q running && echo ok

is fine.  There are also no troubles if a pattern is not matching
(say 'grep -q xunning') or if instead of '-q' something like that is
used:

# service syslog status | grep running >/dev/null 2>&1 && echo ok

Trying in my /etc/rc.d/init.d/ directory the following script

grep -l 'status)' * | while read s ; do
    echo $s
    service $s status | grep -q running
done

I got that "Broken pipe" error for 'nfs' and 'syslog'.  As far as
I can tell they are the only services I have for which "status" will
produce multiple lines with "running" in them.  The same effects
can be observed on RH9 and RH7.3 installations and also with LANG
set to C or unset so this does not seem to be a problem for
a change.  For example:

sh -x /sbin/service syslog status | grep -q running

will show with LANG unset (for example, but this is not a factor)

....
+ env -i LANG= /etc/init.d/syslog status
/sbin/service: line 65: 19038 Broken pipe             env -i LANG=$LANG
"${SERVICEDIR}/${SERVICE}" ${OPTIONS}

but a direct

env -i LANG= /etc/init.d/syslog status | grep -q running

is not causing any trouble.

Also "folding" an output like that:

(res=$(service syslog status); echo $res) | grep -q running && echo ok

works as expected; this includes services which are not running.

So far I am out of further ideas.

Comment 1 Bill Nottingham 2005-09-30 19:57:01 UTC
Closing bugs on older, no longer supported, releases. Apologies for any lack of
response.

I can't reproduce this in brief testing on FC4. Assuming fixed.