When working with a TCP socket under Linux, you will get SIGPIPE if the other side is unexpectedly closed.
Since you can mask this signal (most of the time you will process the return value of 0 yourself, you do not need this signal), I think that the system library checks the signal status, and if masked, use a faster code path.
If not, he cannot optimize.
By the way, do you know about pselect () correctly?
source share