diff --git a/src/daemon.c b/src/daemon.c
index dd3e61d..cefbc26 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -36,8 +36,8 @@
int daemonize = 1;
int verbose = 0;
-sig_atomic_t do_exit = 0;
-sig_atomic_t do_reload = 0;
+volatile sig_atomic_t do_exit = 0;
+volatile sig_atomic_t do_reload = 0;
int write_pid(int pid)
{
diff --git a/src/daemon.h b/src/daemon.h
index b935a34..2704d73 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -18,8 +18,8 @@
#include <signal.h>
-extern sig_atomic_t do_exit;
-extern sig_atomic_t do_reload;
+extern volatile sig_atomic_t do_exit;
+extern volatile sig_atomic_t do_reload;
/**
* Write the PID of the forked daemon to the
Declare signal flags volatile
do_exit and do_reload are set from signal handlers and polled in the main loop. Without volatile the compiler may cache them, which only happened to work because the loop calls external functions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64dfd359d69ee60137b15c2028e35a2a72c4bf2f
Andrew Gaul <andrew@gaul.org> · 2026-11-08T11:29 ·
browse files at this commit
parents:
7eeb9dc