From b01ce2cfd0e0182384cffe7db0c0b94c3414c610 Mon Sep 17 00:00:00 2001 From: LinkTed Date: Tue, 22 Sep 2020 13:17:12 +0200 Subject: [PATCH] Fix `MSG_CMSG_CLOEXEC` for macos --- library/std/src/sys/unix/net.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 2bd6b84d671..8f28c75641f 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -237,6 +237,15 @@ impl Socket { self.recv_from_with_flags(buf, 0) } + #[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + ))] pub fn recv_msg(&self, msg: &mut libc::msghdr) -> io::Result { let n = cvt(unsafe { libc::recvmsg(self.0.raw(), msg, libc::MSG_CMSG_CLOEXEC) })?; Ok(n as usize) @@ -259,6 +268,15 @@ impl Socket { self.0.is_write_vectored() } + #[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + ))] pub fn send_msg(&self, msg: &mut libc::msghdr) -> io::Result { let n = cvt(unsafe { libc::sendmsg(self.0.raw(), msg, 0) })?; Ok(n as usize)