cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
shutdown.h
Go to the documentation of this file.
1
9#ifndef __CWIST_SHUTDOWN_H__
10#define __CWIST_SHUTDOWN_H__
11
12#include <stdatomic.h>
13#include <cwist/sys/platform.h>
14/* WASI preview1 has no signals (wasi-libc's <signal.h> is a hard #error
15 * without emulation), nor does bare metal; signal-based shutdown is
16 * compiled out there. */
17#ifndef CWIST_PLATFORM_NO_PROC
18#include <signal.h>
19#endif
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
26extern atomic_int g_cwist_running;
27
29extern int g_cwist_listen_fd;
30
32extern int g_cwist_udp_fd;
33
36
44
52
59void cwist_shutdown_request(void);
60
64void cwist_shutdown_reset(void);
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif
Target capability macros shared by all CWIST sources.
int g_cwist_drain_timeout_sec
Drain timeout in seconds before process exits.
Definition shutdown.c:24
void cwist_shutdown_request(void)
Request a graceful shutdown, as SIGTERM/SIGINT do: clear the running flag and shut down the listening...
Definition shutdown.c:63
int g_cwist_listen_fd
Registered TCP listening socket (for signal-handler closure).
Definition shutdown.c:18
atomic_int g_cwist_running
Global running flag. Checked by all server event loops.
Definition shutdown.c:17
void cwist_shutdown_install_handlers(void)
Install SIGTERM and SIGINT handlers for graceful shutdown.
Definition shutdown.c:111
void cwist_shutdown_restore_handlers(void)
Put back the SIGTERM and SIGINT handlers that were in place before cwist_shutdown_install_handlers()....
Definition shutdown.c:133
int g_cwist_udp_fd
Registered UDP socket for HTTP/3 (for signal-handler closure).
Definition shutdown.c:19
void cwist_shutdown_reset(void)
Reset shutdown state (useful in test suites).
Definition shutdown.c:173