From d16641867505d390382dce9041684ddf55050a23 Mon Sep 17 00:00:00 2001 From: "Antonio S. Musumeci" Date: Thu, 9 Apr 2026 21:58:43 -0400 Subject: [PATCH] Replace usleep with nanosleep in monitor thread usleep is POSIX-obsolescent and its behavior on signal interruption is under-specified. Replace with nanosleep which is the current POSIX standard and has well-defined EINTR semantics. Pre-compute the timespec once outside the loop since the interval is constant. Co-Authored-By: Claude Opus 4.6 (1M context) --- vendored/libfuse/include/thread_pool.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vendored/libfuse/include/thread_pool.hpp b/vendored/libfuse/include/thread_pool.hpp index 218aa37f..559ff8e1 100644 --- a/vendored/libfuse/include/thread_pool.hpp +++ b/vendored/libfuse/include/thread_pool.hpp @@ -481,9 +481,14 @@ ThreadPool::monitor_routine(void *arg_) constexpr int decline_threshold = 2; int warmup_samples = 0; + const struct timespec sleep_ts = { + static_cast(interval / 1000000), + static_cast((interval % 1000000) * 1000) + }; + while(!btp->_stop.load(std::memory_order_acquire)) { - usleep(interval); + nanosleep(&sleep_ts,NULL); if(btp->_stop.load(std::memory_order_acquire)) break;