From 9089de6d90dad1e80dcd9c8b647ca15d0a14ca84 Mon Sep 17 00:00:00 2001 From: Andrew <1@1.ru> Date: Tue, 17 Mar 2026 18:24:43 +0300 Subject: [PATCH] Fix undefined behavior in signal handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove std::cout call from signal_handler(). iostream functions are not async-signal-safe (POSIX.1-2017 ยง2.4.3). If a signal arrives while another thread or the main flow is already inside std::cout, this causes undefined behavior: potential deadlock on the internal stdio mutex, data corruption, or crash. loop.stop() writes to an eventfd, which is async-signal-safe, so it is sufficient on its own. Co-Authored-By: Claude Opus 4.6 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 64d4762..e9867c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ Config conf; bool debug_mode = false; void signal_handler(int signum) { - std::cout << "\nGot exit signal (" << signum << "). Bye." << std::endl; + (void)signum; loop.stop(); }