darwin, freebsd: set SO_NOSIGPIPE on sockets

Suppresses delivery of SIGPIPE signals when the remote end of the socket has
gone away.
This commit is contained in:
Ben Noordhuis 2012-11-22 17:51:54 +01:00
parent dcd3b55c19
commit 90271e1a3c

View File

@ -325,6 +325,13 @@ int uv__socket(int domain, int type, int protocol) {
sockfd = -1;
}
#if defined(SO_NOSIGPIPE)
{
int on = 1;
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
}
#endif
out:
return sockfd;
}