os.write on a closed socket triggers SIGPIPE
Calling os.write() on a peer-closed socket without the MSG_NOSIGNAL flag triggers a SIGPIPE, rather than return an EPIPE errno.
Would the right thing to do be to set MSG_NOSIGNAL by default on network sockets? I just ran into this, seems like a horrible default behavior to have a network program exit without any message when the remote end closes
Correct, the best thing to do by default on network sockets is MSG_NOSIGNAL
I was asking if the stdlib should set it automatically, but I just realized it seems to be Linux-specific... there seems to be no equivalent to the MSG constants on windows for example.
Windows doesn't have SIGPIPE. It does the equivalent of MSG_NOSIGNAL and returns the windows version of EPIPE (BROKEN_PIPE).
This doesn't break on windows because it doesn't need to do this.