From eaa93090c75ee7893ad8eaffb2a5a23d9d6554af Mon Sep 17 00:00:00 2001 From: Kamil Skalski Date: Mon, 24 Mar 2025 11:27:27 +0800 Subject: [PATCH 1/2] doc(socket): add note on how to enable NONBLOCK on macOS --- src/sys/socket/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index e26e327d78..2114421035 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -290,6 +290,9 @@ libc_bitflags! { /// Additional socket options pub struct SockFlag: c_int { /// Set non-blocking mode on the new socket + /// + /// Note: macOS supports `NONBLOCK` through separate call to `fcntl`, + /// i.e. `nix::fcntl::fcntl(fd, F_SETFL(O_NONBLOCK))` #[cfg(any(linux_android, freebsdlike, netbsdlike, From 0170654a4ac916ccc480fa6d0bce8668d1743a95 Mon Sep 17 00:00:00 2001 From: Kamil Skalski Date: Mon, 24 Mar 2025 11:32:27 +0800 Subject: [PATCH 2/2] Also document CLOEXEC --- src/sys/socket/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 2114421035..247cbe4d5e 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -292,13 +292,16 @@ libc_bitflags! { /// Set non-blocking mode on the new socket /// /// Note: macOS supports `NONBLOCK` through separate call to `fcntl`, - /// i.e. `nix::fcntl::fcntl(fd, F_SETFL(O_NONBLOCK))` + /// e.g. `nix::fcntl::fcntl(fd, F_SETFL(O_NONBLOCK))` #[cfg(any(linux_android, freebsdlike, netbsdlike, solarish))] SOCK_NONBLOCK; /// Set close-on-exec on the new descriptor + /// + /// Note: macOS supports `CLOEXEC` through separate call to `fcntl`, + /// e.g. `nix::fcntl::fcntl(fd, F_SETFL(O_CLOEXEC))` #[cfg(any(linux_android, freebsdlike, netbsdlike,