Bug 104788 - Strange "Broken pipe" from /sbin/service
Summary: Strange "Broken pipe" from /sbin/service
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: initscripts
Version: 9
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
Depends On:
TreeView+ depends on / blocked
Reported: 2003-09-22 00:11 UTC by Michal Jaegermann
Modified: 2014-03-17 02:38 UTC (History)
1 user (show)

Clone Of:
Last Closed: 2005-09-30 19:57:01 UTC

Attachments (Terms of Use)

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

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

# 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

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

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

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

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