4 releases
new 0.2.0 | Feb 10, 2025 |
---|---|
0.1.0 |
|
0.0.3 |
|
0.0.2 | Dec 8, 2024 |
0.0.0 | Nov 28, 2024 |
#442 in Unix APIs
33 downloads per month
Used in scuffle-image-processor
34KB
509 lines
scuffle-signal
[!WARNING]
This crate is under active development and may not be stable.
A crate designed to provide a more user friendly interface to tokio::signal
.
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 user_defined1 = SignalKind::interrupt();
let terminate = SignalKind::terminate();
match signal {
interrupt => {
// Handle SIGINT
println!("received SIGINT");
},
terminate => {
// Handle SIGTERM
println!("received SIGTERM");
},
}
Status
This crate is currently under development and is not yet stable.
Unit tests are not yet fully implemented. Use at your own risk.
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
~104K SLoC