Skip to content

Commit

Permalink
std::net: Socket::new_raw set to SO_NOSIGPIPE on freebsd/netbsd/drago…
Browse files Browse the repository at this point in the history
…nfly.
  • Loading branch information
devnexen committed Apr 28, 2024
1 parent 91d5e4a commit 8131774
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions library/std/src/sys/pal/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ impl Socket {
cfg_if::cfg_if! {
if #[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
target_os = "hurd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "nto",
))] {
Expand All @@ -93,9 +90,9 @@ impl Socket {
fd.set_cloexec()?;
let socket = Socket(fd);

// macOS and iOS use `SO_NOSIGPIPE` as a `setsockopt`
// macOS, iOS and FreeBSD use `SO_NOSIGPIPE` as a `setsockopt`
// flag to disable `SIGPIPE` emission on socket.
#[cfg(target_vendor = "apple")]
#[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "dragonfly"))]
setsockopt(&socket, libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1)?;

Ok(socket)
Expand Down

0 comments on commit 8131774

Please sign in to comment.