MacOS can raise a SIGPIPE when a local socket gets disconnected.
int s = socket_in_netns(aip->ai_family, aip->ai_socktype, aip->ai_protocol, mesh->netns);
+#ifdef SO_NOSIGPIPE
+ int nosigpipe = 1;
+ setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe));
+#endif
+
if(s >= 0) {
set_timeout(s, 5000);
continue;
}
+#ifdef SO_NOSIGPIPE
+ int nosigpipe = 1;
+ setsockopt(state.sock, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe));
+#endif
+
set_timeout(state.sock, 5000);
if(connect(state.sock, aip->ai_addr, aip->ai_addrlen)) {
int lowdelay = IPTOS_LOWDELAY;
setsockopt(c->socket, IPPROTO_IP, IP_TOS, (void *)&lowdelay, sizeof(lowdelay));
#endif
+
+#if defined(SO_NOSIGPIPE)
+ int nosigpipe = 1;
+ setsockopt(c->socket, SOL_SOCKET, SO_NOSIGPIPE, (void *)&nosigpipe, sizeof(nosigpipe));
+#endif
}
static void retry_outgoing_handler(event_loop_t *loop, void *data) {
return 1;
}
} else {
+#ifdef SO_NOSIGPIPE
+ int nosigpipe = 1;
+ setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe));
+#endif
+
if(connect(s, ai->ai_addr, ai->ai_addrlen)) {
debug("Could not connect: %s\n", strerror(errno));
return 1;