Subject: bug#23031: reporting write errors and handling SIGPIPE

From: Paul Eggert <[email-masked]>
Date: Wed, 16 Mar 2016 14:23:15 -0700

On 03/16/2016 09:14 AM, Assaf Gordon wrote:
> write(1, "2\n", 2)                      = -1 EPIPE (Broken pipe)
>    --- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=2893, 
> si_uid=1004} ---
>    write(2, "./src/grep: ", 12)            = 12 

Although this looks weird and it's not what I would expect, it's not a 
POSIX violation as far as I can see. The system is required to send a 
SIGPIPE signal in this case, but it is not required to deliver the 
SIGPIPE signal before 'write' returns with errno == EPIPE. Arguably it's 
a bug in GNU/Linux anyway.

Your patch is a step in the right direction, but needs a bit of cleanup; 
I plan to look into it more carefully later. Thanks!