Skip to content

Commit

Permalink
Rollup merge of rust-lang#128259 - sunshowers:msg-nosignal, r=Mark-Si…
Browse files Browse the repository at this point in the history
…mulacrum

[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 TCP sockets now error out with EPIPE. (Under ordinary circumstances UDP writes won't cause MSG_NOSIGNAL.)

However, I couldn't find any existing tests which verified the MSG_NOSIGNAL behavior.
  • Loading branch information
tgross35 authored Jul 27, 2024
2 parents d6f970a + 2986bfe commit 4ea98d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions std/src/os/unix/net/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use crate::{fmt, io};
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_os = "haiku",
target_os = "nto",
))]
Expand All @@ -31,6 +33,8 @@ use libc::MSG_NOSIGNAL;
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_os = "haiku",
target_os = "nto",
)))]
Expand Down
1 change: 1 addition & 0 deletions std/src/sys_common/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cfg_if::cfg_if! {
target_os = "hurd",
target_os = "dragonfly", target_os = "freebsd",
target_os = "openbsd", target_os = "netbsd",
target_os = "solaris", target_os = "illumos",
target_os = "haiku", target_os = "nto"))] {
use libc::MSG_NOSIGNAL;
} else {
Expand Down

0 comments on commit 4ea98d7

Please sign in to comment.