From: David Tardon Date: Tue, 16 Aug 2022 11:30:16 +0000 (+0200) Subject: fix(skipcpio): ignore broken pipe X-Git-Tag: 058~178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa0369a4a31764fde06214358b0774fb1095af01;p=thirdparty%2Fdracut.git fix(skipcpio): ignore broken pipe If lsinitrd is called from a context in which SIGPIPE is ignored (e.g., from a systemd unit with default setting of IgnoreSIGPIPE=), the following line will result in an error being issued: bin="$($SKIP "$image" | { read -r -N 6 bin && echo "$bin"; })" An example error from `kdumpctl start` (which internally just calls `systemctl start kdump.service`): kdumpctl[1287]: ERROR: src/skipcpio/skipcpio.c:191:main(): fwrite A minimal reproducer: systemd-run -t sh -c '/path/to/skipcpio /path/to/any/file | false' --- diff --git a/src/skipcpio/skipcpio.c b/src/skipcpio/skipcpio.c index 13bfaf536..f66c18694 100644 --- a/src/skipcpio/skipcpio.c +++ b/src/skipcpio/skipcpio.c @@ -23,6 +23,7 @@ #define _GNU_SOURCE #endif +#include #include #include #include @@ -187,8 +188,10 @@ cat_rest: goto end; } + errno = 0; if (fwrite(buf.copy_buffer, 1, s, stdout) != s) { - pr_err("fwrite\n"); + if (errno != EPIPE) + pr_err("fwrite\n"); goto end; } }