#include "CSignalSupport.h" #include #include #include #include static char g_socket_path[104 * 4]; static volatile sig_atomic_t g_has_path = 0; void reyna_store_socket_path(const char *path) { if (!path) { g_socket_path[0] = '\0'; g_has_path = 0; return; } strncpy(g_socket_path, path, sizeof(g_socket_path)-1); g_socket_path[sizeof(g_socket_path)-1] = '\0'; g_has_path = 1; } void reyna_cleanup_socket_sync(void) { if (!g_has_path) return; if (g_socket_path[0] == '\0') return; unlink(g_socket_path); } static void reyna_signal_handler(int sig) { (void)sig; reyna_cleanup_socket_sync(); _exit(0); } void reyna_install_signal_handlers(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = reyna_signal_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGTERM, &sa, NULL); sigaction(SIGINT, &sa, NULL); sigaction(SIGHUP, &sa, NULL); signal(SIGPIPE, SIG_IGN); }