Hi,

Recently I was porting a program that uses Boost Asio to OpenBSD and
found it was exiting frequently with SIGPIPE. This doesn't happen on
Linux because on that platform Asio passes the MSG_NOSIGNAL flag to
sendmsg(2). (It doesn't on FreeBSD either because Asio uses the
SO_NOSIGNAL socket option there.)

The patch below for Boost 1.67 sets MSG_NOSIGNAL on OpenBSD too. Could
you add it to the patches in the ports tree? I've also submitted it
upstream [1] but not sure if/when it will be applied.

--- boost/asio/detail/impl/socket_ops.ipp.orig  Sun Sep 20 09:48:05 2020
+++ boost/asio/detail/impl/socket_ops.ipp       Sun Sep 20 09:52:00 2020
@@ -1178,7 +1178,7 @@
   msghdr msg = msghdr();
   msg.msg_iov = const_cast<buf*>(bufs);
   msg.msg_iovlen = static_cast<int>(count);
-#if defined(__linux__)
+#if defined(__linux__) || defined(__OpenBSD__)
   flags |= MSG_NOSIGNAL;
 #endif // defined(__linux__)
   signed_size_type result = error_wrapper(::sendmsg(s, &msg, flags), ec);
@@ -1307,7 +1307,7 @@
   msg.msg_namelen = static_cast<int>(addrlen);
   msg.msg_iov = const_cast<buf*>(bufs);
   msg.msg_iovlen = static_cast<int>(count);
-#if defined(__linux__)
+#if defined(__linux__) || defined(__OpenBSD__)
   flags |= MSG_NOSIGNAL;
 #endif // defined(__linux__)
   signed_size_type result = error_wrapper(::sendmsg(s, &msg, flags), ec);


[1] https://github.com/chriskohlhoff/asio/pull/549

--
Thanks,
Nick

Reply via email to