6#define _POSIX_C_SOURCE 200809L
13#ifndef CWIST_PLATFORM_NO_PROC
14#include <sys/socket.h>
35 const char *
env =
getenv(
"CWIST_DRAIN_TIMEOUT");
39 if (
end && *
end ==
'\0' &&
v >= 0 &&
v <= 3600) {
42 fprintf(
stderr,
"[CWIST] Ignoring invalid CWIST_DRAIN_TIMEOUT=\"%s\" (using default %d)\n",
70#ifndef CWIST_PLATFORM_NO_PROC
81#ifndef CWIST_PLATFORM_NO_PROC
86static void cwist_shutdown_handler(
int sig) {
92#ifndef CWIST_PLATFORM_NO_PROC
99static bool g_prev_saved =
false;
115 sa.sa_handler = cwist_shutdown_handler;
134 if (!g_prev_saved)
return;
137 g_prev_saved =
false;
__attribute__((constructor))
int g_cwist_drain_timeout_sec
Drain timeout in seconds before process exits.
void cwist_shutdown_request(void)
Request a graceful shutdown of the server.
int g_cwist_listen_fd
Registered TCP listening socket (for signal-handler closure).
atomic_int g_cwist_running
Global running flag. Checked by all server event loops.
void cwist_shutdown_install_handlers(void)
Install CWIST's SIGTERM/SIGINT handlers.
void cwist_shutdown_restore_handlers(void)
Restore the SIGTERM/SIGINT handlers saved by the first cwist_shutdown_install_handlers() call.
int g_cwist_udp_fd
Registered UDP socket for HTTP/3 (for signal-handler closure).
void cwist_shutdown_reset(void)
Reset shutdown state so the process can serve again.
Unified Graceful Shutdown support for CWIST.