Subject: bug#64540: [PATCH] od: exit out on failure to write to stdout

From: Paul Eggert <[email-masked]>
Date: Sun, 9 Jul 2023 02:29:52 -0700

On 2023-07-08 15:43, Josef Bacik wrote:
> A very weird bug was uncovered when using fstests with github actions.
> In fstests we are doing something like this
> 
> od /dev/urandom | dd of=somefile bs=1M count=10
> 
> The above works fine, except in the case of github actions which runs
> this script remotely, capturing the output in a pipe to print on their
> console.  Somehow od ends up writing forever into the stdout pipe
> without exiting in this scenario, normally it doesn't do this.

Do you see the same problem if you use 'cat' rather than 'od'? If so, 
the problem isn't with 'od'; it's with the environment, which is somehow 
set up to ignore SIGPIPE. It shouldn't do that, as ignoring SIGPIPE 
breaks a lot of programs, and 'od' would be just one of them.

Although the patch you sent is probably harmless, it's not clear that we 
should go through all the GNU utilities and make them check for I/O 
errors on every output, as that'd be a maintenance hassle and in some 
cases would hurt performance significantly.