Expand description
The process-wide shutdown flag std/http’s Server::listen polls (see
its module doc and docs/adr/0022-process-shutdown-signals.md). pub,
unlike [time], so tests/signal_*.rs can drive it.
The process-wide shutdown flag behind std/http’s graceful
Server::listen.
One AtomicBool, set by the first termination request the process
receives: SIGTERM or SIGINT on Unix, CTRL_BREAK or CTRL_C on Windows. A
request that arrives once the flag is already set takes the signal’s
default action instead, so a stalled shutdown can always be ended.
Opt-in, and permanent once in. Nothing is installed until the first
call to nova_rt_shutdown_requested, which only std/http’s Server
makes: the builtin shutdown_requested is STD_ONLY. A program that never
calls it keeps every signal’s default action. Once installed, the handler
stays for the life of the process, and the flag is never cleared.
The handler touches nothing but [SHUTDOWN]. On Unix it runs in signal
context, where only async-signal-safe calls are allowed. On Windows the OS
runs it on a thread of its own, where this crate’s thread_local! state
(the executor, the socket table, the heap) is a different, empty copy. So
it never wakes the executor: poll.rs retries an interrupted wait, and Nova
code sees the flag at its next deadline. Server::listen provides one
every 100 ms. docs/adr/0022-process-shutdown-signals.md records the
decision and the alternatives it rejected.
An inherited ignore stays ignored. A process started with SIGINT ignored (a job backgrounded by a non-interactive shell) keeps ignoring it. Windows’ inherited Ctrl-C ignore flag keeps CTRL_C from reaching any handler at all. SIGTERM and CTRL_BREAK are not affected.
pub, unlike [crate::time], so the integration tests under
crates/nova-runtime/tests/ can drive it. Each process-global scenario
there is its own test binary, because neither the install nor the flag can
be undone within one process.
Functions§
- nova_
rt_ shutdown_ requested shutdown_requested() -> Bool: installs the handler on the first call, then reports whether the flag is set, as1or0.