Skip to main content

Module shutdown

Module shutdown 

Source
Expand description

Wall-clock timeout, signal awareness, and cancel racing for one-shot runs.

§Workload classification (Rules Rust — parallelism)

  • Class: signal/deadline coordination on the multi-thread one-shot runtime (see src/main.rs and crate::concurrency).
  • Fan-out bound: fixed auxiliary tasks — at most one double-interrupt watcher and one ProgressGuard timer per command (abort-on-drop). Product CPU/HTTP admission lives in crate::concurrency::ConcurrencyBudget.
  • Shared state: CancelFlag and progress done use Arc<Atomic*> (SeqCst), never Mutex across .await.

§Shutdown model (CLI one-shot)

Product policy is minimum + pipeline-critical shutdown, not daemon coordination: detect (signals / deadline) → signal (CancelFlag) → await (race + flush) → DIE.

  • Unix: SIGINT → interrupt (130); SIGTERM / SIGHUP → terminate (143)
  • Windows: Ctrl+C → interrupt; Ctrl+Break / Ctrl+Close → terminate
  • Second SIGINT / Ctrl+C within DOUBLE_INTERRUPT_FORCE_SECS force-exits 130 after flush
  • stdout BrokenPipe is mapped by callers to exit 141 (Rust ignores SIGPIPE by default)

Structs§

CancelFlag
Shared cancel flag checked by HTTP retries between attempts.
CancelPoll
Helper future that polls cancel between retries (used by tests).
ProgressGuard
Progress reporter: after delay, emit one localized line to stderr if still running.

Enums§

CancelKind
Which OS signal cancelled the process.

Constants§

DOUBLE_INTERRUPT_FORCE_SECS
Window for second SIGINT to force-exit (Rules Rust: double Ctrl-C).

Functions§

duration_ms
Elapsed milliseconds since start.
flush_stdio
Flush stdout and stderr best-effort (FINALIZE).
race_op_with_cancel_and_deadline
Race an operation against cancel signals and an optional wall-clock deadline.
spawn_double_interrupt_force_exit
Install a process-wide second-SIGINT force-exit watcher.
wait_for_cancel
Future that completes when a cancel signal arrives.
with_wall_clock
Run a future with a wall-clock deadline.