I'm working with some code that needs to be safe against killing the caller due to SIGPIPE
, but the only socket writes it's performing are going to datagram sockets (both UDP and Unix domain datagram sockets). Do I need to worry about SIGPIPE
? I'm using connect
on the socket, but preliminary testing (on Linux) showed that I just get ECONNREFUSED
on send if there's nobody listening on the Unix domain socket. Not sure what happens with UDP.
I can wrap the whole thing in hacks to get rid of SIGPIPE
, but if it's a non-issue I'd rather save the overhead and keep the code complexity down.
The answer is in the specification for send
:
[EPIPE] The socket is shut down for writing, or the socket is connection-mode and is no longer connected. In the latter case, and if the socket is of type SOCK_STREAM or SOCK_SEQPACKET and the MSG_NOSIGNAL flag is not set, the SIGPIPE signal is generated to the calling thread.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html
Thus, no, writes to datagram sockets do not generate SIGPIPE
or an EPIPE
error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With