Assaf Gordon wrote:
If the issue of cat(1) supporting socketpair/ECONNRESET instead of
pipes/EPIPE is still relevant, we can re-open the bug.
'cat' treats EPIPE on pipes the same way it treats ECONNRESET on socket pairs:
$ (trap '' PIPE; cat /usr/bin/emacs) | :
cat: write error: Broken pipe
The difference in observed behavior occurs only because most scripts (rightly)
don't ignore SIGPIPE. If we change 'cat' to ignore ECONNRESET, for consistency
we should also change it to ignore EPIPE.
The POSIX spec[1] allows 'write' to send a SIGPIPE and set errno to EPIPE for
sockets that are no longer connected. I wonder why the Linux kernel doesn't do
that? It would seem to be more consistent and useful.
[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html