On Mac, this is done by setting SO_NOSIGPIPE on the socket. On Linux, this is done with MSG_NOSIGNAL on the send call.