I'm wondering what was the thinking behind having a SIGPIPE
signal.
From my own experience, the first thing I do is turn off that signal (SIGIGN
) and use the return value of the calls to make sure it isn't now closed (i.e. errno == EPIPE
).
The only one thing I could come up with is: programmers at the time wanted to pipe between processes in a shell so they would do work until the first SIGPIPE
and just exit. However, even that, if you pipe-in and pipe-out, then you'd need to know whether the SIGPIPE
was for the input and if so continue the work until your data was all processed... I guess you can first assume that the SIGPIPE
was from the input and not fail. If you receive SIGPIPE
again, just fail.
So even early on, the signal would be difficult to work with, wouldn't it?
P.S. I'm not interested about sockets that came later.