Skip to content

Commit

Permalink
std::net: Socket::new_raw no set to SO_NOSIGPIPE on freebsd.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Apr 28, 2024
1 parent 91d5e4a commit 7a878ea
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions library/std/src/sys/pal/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ impl Socket {
if #[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
target_os = "hurd",
target_os = "linux",
Expand All @@ -93,9 +92,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"))]
setsockopt(&socket, libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1)?;

Ok(socket)
Expand Down

0 comments on commit 7a878ea

Please sign in to comment.