Mailinglist Archive: opensuse (794 mails)

< Previous Next >
Re: [opensuse] systemd - zgrep -m1 gives me "gzip: stdout: Broken pipe" ?
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 being
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). 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.

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

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

< Previous Next >
Follow Ups
References