This commit is contained in:
2026-09-13 13:30:21 +08:00
commit a6bbd520cf
2744 changed files with 1598795 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
#include "SignalStop.h"
#include <csignal>
volatile bool g_devourer_should_stop = false;
static void devourer_stop_handler(int /*sig*/) { g_devourer_should_stop = true; }
void install_devourer_signal_handlers() {
#ifdef _WIN32
/* Windows has no POSIX sigaction; std::signal covers SIGINT/SIGTERM and is
* enough for the demos' Ctrl-C / terminate stop semantics. */
std::signal(SIGINT, devourer_stop_handler);
std::signal(SIGTERM, devourer_stop_handler);
#else
struct sigaction sa {};
sa.sa_handler = devourer_stop_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0; /* no SA_RESTART: let blocking syscalls return so loops re-check */
sigaction(SIGINT, &sa, nullptr);
sigaction(SIGTERM, &sa, nullptr);
#endif
}