From fc6e57c3fa8a1068f1ff69ea7ff06f97d1c40eba Mon Sep 17 00:00:00 2001 From: noctuum <25441068+noctuum@users.noreply.github.com> Date: Mon, 28 Sep 2026 00:50:54 +0500 Subject: [PATCH] Check pthread_sigmask by its return value `pthread_sigmask` returns the error number and does not set `errno`. --- src/signal_handler.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/signal_handler.cc b/src/signal_handler.cc index 3d5bbf27..66e89e5e 100644 --- a/src/signal_handler.cc +++ b/src/signal_handler.cc @@ -63,8 +63,10 @@ SignalHandler::set_block(unsigned int signum) { sigemptyset(&mask); sigaddset(&mask, signum); - if (pthread_sigmask(SIG_BLOCK, &mask, NULL) == -1) - throw std::logic_error("Could not block signal: " + std::string(std::strerror(errno))); + int result = pthread_sigmask(SIG_BLOCK, &mask, NULL); + + if (result != 0) + throw std::logic_error("Could not block signal: " + std::string(std::strerror(result))); } void @@ -77,8 +79,10 @@ SignalHandler::set_unblock(unsigned int signum) { sigemptyset(&mask); sigaddset(&mask, signum); - if (pthread_sigmask(SIG_UNBLOCK, &mask, NULL) == -1) - throw std::logic_error("Could not unblock signal: " + std::string(std::strerror(errno))); + int result = pthread_sigmask(SIG_UNBLOCK, &mask, NULL); + + if (result != 0) + throw std::logic_error("Could not unblock signal: " + std::string(std::strerror(result))); } void