[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.)
This commit is contained in:
Rain 2024-07-27 02:06:58 +00:00 committed by Rain
parent 2d5a628a1d
commit 50d127e6ec
2 changed files with 5 additions and 0 deletions

View File

@ -20,6 +20,8 @@
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_os = "haiku",
target_os = "nto",
))]
@ -31,6 +33,8 @@
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_os = "haiku",
target_os = "nto",
)))]

View File

@ -42,6 +42,7 @@
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 {