8 releases

Uses new Rust 2024

new 0.3.2 May 17, 2025
0.3.1 May 15, 2025
0.3.0 Apr 27, 2025
0.2.1 Feb 21, 2025
0.0.0 Nov 28, 2024

#587 in Unix APIs

Download history 207/week @ 2025-02-04 120/week @ 2025-02-11 145/week @ 2025-02-18 36/week @ 2025-02-25 25/week @ 2025-03-04 15/week @ 2025-03-11 7/week @ 2025-03-18 2/week @ 2025-03-25 1/week @ 2025-04-01 6/week @ 2025-04-08 1/week @ 2025-04-15 97/week @ 2025-04-22 37/week @ 2025-04-29 19/week @ 2025-05-06 322/week @ 2025-05-13

475 downloads per month
Used in scuffle-image-processor

MIT/Apache

54KB
823 lines

scuffle-signal

[!WARNING]
This crate is under active development and may not be stable.

License: MIT OR Apache-2.0 docs.rs crates.io GitHub Actions: ci Codecov


A crate designed to provide a more user friendly interface to tokio::signal.

See the changelog for a full release history.

Feature flags

  • bootstrap — Enables scuffle-bootstrap support
  • docs — Enables changelog and documentation of feature flags

Why do we need this?

The tokio::signal module provides a way for us to wait for a signal to be received in a non-blocking way. This crate extends that with a more helpful interface allowing the ability to listen to multiple signals concurrently.

Example

use scuffle_signal::SignalHandler;
use tokio::signal::unix::SignalKind;

let mut handler = SignalHandler::new()
    .with_signal(SignalKind::interrupt())
    .with_signal(SignalKind::terminate());

// Wait for a signal to be received
let signal = handler.await;

// Handle the signal
let interrupt = SignalKind::interrupt();
let terminate = SignalKind::terminate();
match signal {
    interrupt => {
        // Handle SIGINT
        println!("received SIGINT");
    },
    terminate => {
        // Handle SIGTERM
        println!("received SIGTERM");
    },
}

License

This project is licensed under the MIT or Apache-2.0 license. You can choose between one of them if you use this work.

SPDX-License-Identifier: MIT OR Apache-2.0

Dependencies

~2–11MB
~110K SLoC