From 3de9ecce60788695f4c854ff0efe93c60f422955 Mon Sep 17 00:00:00 2001 From: Denys Khomenko Date: Thu, 12 Nov 2026 13:24:33 +0200 Subject: [PATCH 1/2] Block SIGPIPE only on the OLP SDK cURL worker Blocking SIGPIPE at library load changes the caller's signal mask, which can interfere with unrelated application behavior, including writing to closed pipes. Limit SIGPIPE blocking to the SDK cURL worker so the application thread that loads the SDK keeps its existing signal mask. Relates-To: DATASDK-112 Signed-off-by: Denys Khomenko --- .../src/http/curl/NetworkCurl.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp b/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp index 3296e4af1..4b60bfda1 100644 --- a/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp +++ b/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp @@ -137,7 +137,8 @@ std::string CaBundlePath() { #if defined(IGNORE_SIGPIPE) -// Block SIGPIPE signals for the current thread and all threads it creates. +// Block SIGPIPE on the cURL worker thread to prevent writes to closed sockets +// from terminating the process. int BlockSigpipe() { sigset_t sigset; int err; @@ -155,13 +156,6 @@ int BlockSigpipe() { return err; } -// Curl7.35+OpenSSL can write into closed sockets sometimes which results -// in the process being terminated with SIGPIPE on Linux. Here's -// a workaround for that bug. It block SIGPIPE for the startup thread and -// hence for all other threads in the application. The variable itself is -// not used but can be examined. -int BlockSigpipeResult = BlockSigpipe(); - #endif // IGNORE_SIGPIPE #ifdef OLP_SDK_NETWORK_HAS_PIPE2 @@ -1231,6 +1225,15 @@ NetworkCurl::RequestHandle* NetworkCurl::Impl::FindRequestHandle( } void NetworkCurl::Impl::Run() { +#if defined(IGNORE_SIGPIPE) + const auto block_sigpipe_result = BlockSigpipe(); + if (block_sigpipe_result != 0) { + OLP_SDK_LOG_ERROR(kLogTag, + "Failed to block SIGPIPE on cURL worker thread, error=" + << block_sigpipe_result); + } +#endif + olp::utils::Thread::SetCurrentThreadName(kCurlThreadName); { From 33c9ec702d3c9f103a3e458e57ca05b0979ede40 Mon Sep 17 00:00:00 2001 From: Khomenko Denys Date: Fri, 20 Nov 2026 13:45:49 +0200 Subject: [PATCH 2/2] Restore comment about the SIGPIPE blocking Explain why the cURL worker blocks SIGPIPE: certain cURL and OpenSSL combinations can terminate the process when writing to a closed socket. Keeping this rationale helps preserve the intent of the signal handling. Relates-To: DATASDK-112 Signed-off-by: Khomenko Denys --- olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp b/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp index 4b60bfda1..759ff73bc 100644 --- a/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp +++ b/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp @@ -1226,6 +1226,10 @@ NetworkCurl::RequestHandle* NetworkCurl::Impl::FindRequestHandle( void NetworkCurl::Impl::Run() { #if defined(IGNORE_SIGPIPE) + // With some cURL 7.35+ and OpenSSL combinations, writing to a closed socket + // can raise SIGPIPE and terminate the process on Linux. Block SIGPIPE on the + // cURL worker thread to protect SDK network operations without changing the + // signal mask of the thread that initializes the SDK. const auto block_sigpipe_result = BlockSigpipe(); if (block_sigpipe_result != 0) { OLP_SDK_LOG_ERROR(kLogTag,