From 90271e1a3cf69cb56b55b37712d84b17e375cea2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 22 Nov 2012 17:51:54 +0100 Subject: [PATCH] darwin, freebsd: set SO_NOSIGPIPE on sockets Suppresses delivery of SIGPIPE signals when the remote end of the socket has gone away. --- src/unix/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/unix/core.c b/src/unix/core.c index 06d689ca..94074525 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -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; }