File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
library/std/src/sys/pal/unix Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,14 @@ impl Socket {
86
86
// flag to atomically create the socket and set it as
87
87
// CLOEXEC. On Linux this was added in 2.6.27.
88
88
let fd = cvt( libc:: socket( fam, ty | libc:: SOCK_CLOEXEC , 0 ) ) ?;
89
- Ok ( Socket ( FileDesc :: from_raw_fd( fd) ) )
89
+ let socket = Socket ( FileDesc :: from_raw_fd( fd) ) ;
90
+
91
+ // DragonFlyBSD, FreeBSD and NetBSD use `SO_NOSIGPIPE` as a `setsockopt`
92
+ // flag to disable `SIGPIPE` emission on socket.
93
+ #[ cfg( any( target_os = "freebsd" , target_os = "netbsd" , target_os = "dragonfly" ) ) ]
94
+ setsockopt( & socket, libc:: SOL_SOCKET , libc:: SO_NOSIGPIPE , 1 ) ?;
95
+
96
+ Ok ( socket)
90
97
} else {
91
98
let fd = cvt( libc:: socket( fam, ty, 0 ) ) ?;
92
99
let fd = FileDesc :: from_raw_fd( fd) ;
You can’t perform that action at this time.
0 commit comments