Mailinglist Archive: opensuse (794 mails)

< Previous Next >
Re: [opensuse] systemd - zgrep -m1 gives me "gzip: stdout: Broken pipe" ?
  • From: Per Jessen <per@xxxxxxxxxxxx>
  • Date: Wed, 29 Nov 2017 20:01:14 +0100
  • Message-id: <ovn05q$55f$>
Andrei Borzenkov wrote:

29.11.2017 12:51, Per Jessen пишет:
Okay, I need another pair of eyes -

in a bash script, I have "zgrep -m1 SOA file.gz". The script is
run under systemd. The line with SOA is found, but I always get
"gzip: stdout: Broken pipe".

zgrep is obviously "gzip -dc | grep".

I guess grep closes early when the first line is found, but why does
this produce the error when running under systemd? If I remove
the '-m1', no problem, no message.

In the console, if I run the "zgrep -m1" manually or from within a
script, no problem, no message.

If you look with strace you will see that gzip *does* get SIGPIPE. And
if you look at signal mask, you will also see that programs started by
systemd have SIGPIPE ignored (by default).

Right, that is what Bernard wrote about IgnoreSIGPIPE= etc.

And gzip will leave such signal ignored as well. Which means, under
shell gzip gets SIGPIPE and silently exits from within signal handler
(because it is normally not an error, at least, something outside of
program control), while under systemd it never sees SIGPIPE in the
first place, so write function will print this error and abort.

aha! Thanks for taking the time to explain that, I couldn't quite work
it out.

So here we have situation when program *expects* and handles SIGPIPE;
hiding it from the program actually makes things worse :)

Hehe, yeah.

So I were to add "IgnoreSIGPIPE=false", my script would presumably work
as expected.

Per Jessen, Zürich (2.3°C) - your owncloud, hosted in Switzerland.

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >