Skip to content

Commit 50d127e

Browse files
committed
[illumos/solaris] set MSG_NOSIGNAL while writing to sockets
Both these platforms have MSG_NOSIGNAL available, and we should set it for socket writes in the event that the SIGPIPE handler has been reset to SIG_DFL (i.e. terminate the process). I've verified via a quick program at https://github.com/sunshowers/msg-nosignal-test/ that even when the SIGPIPE handler is reset to SIG_DFL, writes to closed sockets now error out with EPIPE. (Under ordinary circumstances UDP writes won't cause MSG_NOSIGNAL.)
1 parent 2d5a628 commit 50d127e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

library/std/src/os/unix/net/datagram.rs

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use crate::{fmt, io};
2020
target_os = "freebsd",
2121
target_os = "openbsd",
2222
target_os = "netbsd",
23+
target_os = "solaris",
24+
target_os = "illumos",
2325
target_os = "haiku",
2426
target_os = "nto",
2527
))]
@@ -31,6 +33,8 @@ use libc::MSG_NOSIGNAL;
3133
target_os = "freebsd",
3234
target_os = "openbsd",
3335
target_os = "netbsd",
36+
target_os = "solaris",
37+
target_os = "illumos",
3438
target_os = "haiku",
3539
target_os = "nto",
3640
)))]

library/std/src/sys_common/net.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cfg_if::cfg_if! {
4242
target_os = "hurd",
4343
target_os = "dragonfly", target_os = "freebsd",
4444
target_os = "openbsd", target_os = "netbsd",
45+
target_os = "solaris", target_os = "illumos",
4546
target_os = "haiku", target_os = "nto"))] {
4647
use libc::MSG_NOSIGNAL;
4748
} else {

0 commit comments

Comments
 (0)