Red Hat Bugzilla – Bug 104788
Strange "Broken pipe" from /sbin/service
Last modified: 2014-03-16 22:38:52 EDT
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
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.
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.