mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Rollup merge of #124470 - devnexen:no_sigpipe_fbsd, r=workingjubilee
std::net: Socket::new_raw now set to SO_NOSIGPIPE on freebsd.
This commit is contained in:
commit
bc42f25b04
@ -86,7 +86,14 @@ impl Socket {
|
||||
// flag to atomically create the socket and set it as
|
||||
// CLOEXEC. On Linux this was added in 2.6.27.
|
||||
let fd = cvt(libc::socket(fam, ty | libc::SOCK_CLOEXEC, 0))?;
|
||||
Ok(Socket(FileDesc::from_raw_fd(fd)))
|
||||
let socket = Socket(FileDesc::from_raw_fd(fd));
|
||||
|
||||
// DragonFlyBSD, FreeBSD and NetBSD use `SO_NOSIGPIPE` as a `setsockopt`
|
||||
// flag to disable `SIGPIPE` emission on socket.
|
||||
#[cfg(any(target_os = "freebsd", target_os = "netbsd", target_os = "dragonfly"))]
|
||||
setsockopt(&socket, libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1)?;
|
||||
|
||||
Ok(socket)
|
||||
} else {
|
||||
let fd = cvt(libc::socket(fam, ty, 0))?;
|
||||
let fd = FileDesc::from_raw_fd(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user