sigterm

Crates.iosigterm
lib.rssigterm
version0.3.9
created_at2026-01-25 12:34:08.329868+00
updated_at2026-01-25 16:06:13.757919+00
descriptionSignal-aware async control and cancellation primitives for Tokio.
homepage
repositoryhttps://github.com/canmi21/sigterm.git
max_upload_size
id2068611
size33,139
Canmi (canmi21)

documentation

README

Sigterm

Signal-aware async control and cancellation primitives for Tokio.

sigterm abstracts away the boilerplate of listening for system signals (Ctrl+C, SIGTERM, etc.) and coordinating shutdown across multiple asynchronous tasks.

Features

  • Signal Waiting: Wait for Ctrl+C or SIGTERM across platforms with a single await. Use try_wait() for non-panicking version.
  • Cancellation Tokens: Hierarchy-based cancellation (parent cancels child) powered by tokio-util.
  • Shutdown Primitives:
    • Shutdown: One-shot channel for single-task termination.
    • Broadcast: Notify multiple subscribers of a shutdown event.
    • ShutdownGuard: RAII guard that triggers shutdown when dropped (useful for panics).
  • Framework Integration: shutdown_signal() helper designed for seamless integration with axum::serve.
  • Unix Extensions: Listen for custom signal sets (SIGHUP, SIGQUIT, etc.) on Unix systems.

Usage Examples

Check the examples directory for runnable code:

Installation

[dependencies]
sigterm = { version = "0.3", features = ["full"] }

License

Released under the MIT License © 2026 Canmi

Commit count: 0

cargo fmt