Skip to content

Commit aa0369a

Browse files
dtardonjohannbg
authored andcommitted
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'
1 parent bdef779 commit aa0369a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/skipcpio/skipcpio.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define _GNU_SOURCE
2424
#endif
2525

26+
#include <errno.h>
2627
#include <stdio.h>
2728
#include <stdlib.h>
2829
#include <string.h>
@@ -187,8 +188,10 @@ int main(int argc, char **argv)
187188
goto end;
188189
}
189190

191+
errno = 0;
190192
if (fwrite(buf.copy_buffer, 1, s, stdout) != s) {
191-
pr_err("fwrite\n");
193+
if (errno != EPIPE)
194+
pr_err("fwrite\n");
192195
goto end;
193196
}
194197
}

0 commit comments

Comments
 (0)