Skip to content

Commit

Permalink
in recvmsg, pass in MSG_CMSG_CLOEXEC on illumos (#373)
Browse files Browse the repository at this point in the history
Support for MSG_CMSG_CLOEXEC was added to illumos in a [recent commit].  To
match the behavior on Linux, pass in the flag on illumos (the definition was
added in libc 0.2.162).

I've verified that the ipc-channel test suite still passes on an older
illumos kernel which doesn't have support for it. This is okay because
for returned fds, cloexec support is effectively best-effort.

[recent commit]: illumos/illumos-gate@0250c53
  • Loading branch information
sunshowers authored Nov 13, 2024
1 parent aa43418 commit 7476ff0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fnv = "1.0.3"
futures = { version = "0.3", optional = true }
futures-test = { version = "0.3", optional = true }
lazy_static = "1"
libc = "0.2.161"
libc = "0.2.162"
rand = "0.8"
serde = { version = "1.0", features = ["rc"] }
uuid = { version = "1", features = ["v4"] }
Expand Down
6 changes: 3 additions & 3 deletions src/platform/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::hash::BuildHasherDefault;
use std::io;
use std::marker::PhantomData;
use std::mem;
use std::ops::{Deref, DerefMut, RangeFrom};
use std::ops::{Deref, RangeFrom};
use std::os::fd::RawFd;
use std::ptr;
use std::slice;
Expand All @@ -54,9 +54,9 @@ const SOCK_FLAGS: c_int = libc::SOCK_CLOEXEC;
#[cfg(not(any(target_os = "linux", target_os = "illumos")))]
const SOCK_FLAGS: c_int = 0;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "illumos"))]
const RECVMSG_FLAGS: c_int = libc::MSG_CMSG_CLOEXEC;
#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "illumos")))]
const RECVMSG_FLAGS: c_int = 0;

#[cfg(target_env = "gnu")]
Expand Down

0 comments on commit 7476ff0

Please sign in to comment.