Index: base/posix/unix_domain_socket.cc |
diff --git a/base/posix/unix_domain_socket.cc b/base/posix/unix_domain_socket.cc |
index 730657dfcdbc4c5f6c87b31f5a659a2ce32abd5a..5bfcef17fef97a10160cbdf2ef988ac7b8ff8957 100644 |
--- a/base/posix/unix_domain_socket.cc |
+++ b/base/posix/unix_domain_socket.cc |
@@ -43,7 +43,14 @@ bool UnixDomainSocket::SendMsg(int fd, |
msg.msg_controllen = cmsg->cmsg_len; |
} |
- const ssize_t r = HANDLE_EINTR(sendmsg(fd, &msg, 0)); |
+ // When available, take advantage of MSG_NOSIGNAL to avoid |
+ // a SIGPIPE if the other end breaks the connection. |
+#if defined(MSG_NOSIGNAL) |
+ const int flags = MSG_NOSIGNAL; |
+#else |
+ const int flags = 0; |
+#endif |
+ const ssize_t r = HANDLE_EINTR(sendmsg(fd, &msg, flags)); |
const bool ret = static_cast<ssize_t>(length) == r; |
delete[] control_buffer; |
return ret; |