From 3bae07fc2956a8af561cc40721cd962b573f1be7 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 16 Nov 2023 12:08:47 -0500 Subject: [PATCH] protocols/unix: Implement MSG_NOSIGNAL. Same logic as in the TCP protocol module. This fixes a regression from hrev57383: curl now works again. (Perhaps it shouldn't be called a "regression", though, but instead an uncovered bug / missing feature.) Fixes #18666. --- .../kernel/network/protocols/unix/UnixDatagramEndpoint.cpp | 4 ++-- .../kernel/network/protocols/unix/UnixStreamEndpoint.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/add-ons/kernel/network/protocols/unix/UnixDatagramEndpoint.cpp b/src/add-ons/kernel/network/protocols/unix/UnixDatagramEndpoint.cpp index 1e0be05e18..a766231e3a 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixDatagramEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/unix/UnixDatagramEndpoint.cpp @@ -215,7 +215,7 @@ UnixDatagramEndpoint::Send(const iovec* vecs, size_t vecCount, TRACE("[%" B_PRId32 "] %p->UnixDatagramEndpoint::Send()\n", find_thread(NULL), this); - if ((flags & ~(MSG_DONTWAIT)) != 0) + if ((flags & ~(MSG_DONTWAIT | MSG_NOSIGNAL)) != 0) return EOPNOTSUPP; bigtime_t timeout = 0; @@ -307,7 +307,7 @@ UnixDatagramEndpoint::Send(const iovec* vecs, size_t vecCount, switch (result) { case EPIPE: - if (gStackModule->is_syscall()) + if (gStackModule->is_syscall() && (flags & MSG_NOSIGNAL) == 0) send_signal(find_thread(NULL), SIGPIPE); break; case B_TIMED_OUT: diff --git a/src/add-ons/kernel/network/protocols/unix/UnixStreamEndpoint.cpp b/src/add-ons/kernel/network/protocols/unix/UnixStreamEndpoint.cpp index 698777bf80..28fa59cdf0 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixStreamEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/unix/UnixStreamEndpoint.cpp @@ -379,7 +379,7 @@ UnixStreamEndpoint::Send(const iovec* vecs, size_t vecCount, TRACE("[%" B_PRId32 "] %p->UnixStreamEndpoint::Send(%p, %ld, %p)\n", find_thread(NULL), this, vecs, vecCount, ancillaryData); - if ((flags & ~(MSG_DONTWAIT)) != 0) + if ((flags & ~(MSG_DONTWAIT | MSG_NOSIGNAL)) != 0) return EOPNOTSUPP; bigtime_t timeout = 0; @@ -454,7 +454,7 @@ UnixStreamEndpoint::Send(const iovec* vecs, size_t vecCount, case EPIPE: // The peer closed connection or shutdown its read side. Reward // the caller with a SIGPIPE. - if (gStackModule->is_syscall()) + if (gStackModule->is_syscall() && (flags & MSG_NOSIGNAL) == 0) send_signal(find_thread(NULL), SIGPIPE); break; case B_TIMED_OUT: