Crates.io | signal-msg |
lib.rs | signal-msg |
version | 0.2.1 |
source | src |
created_at | 2020-02-23 18:39:00.115081 |
updated_at | 2020-02-23 23:10:06.89233 |
description | Handle UNIX process signals with a shared channel (uses simple-signal) |
homepage | |
repository | https://github.com/oxur/signal-msg |
max_upload_size | |
id | 211824 |
size | 8,390 |
Handle UNIX process signals with a shared channel (uses simple-signal)
This project aims to make simple signal handling even simpler: just use
messages. Since passing objects into an anonymous function signal handler can
get tricky, signal-msg
offers an alternative approach of listening for
signals on a receiver.
This library was created for ease of use when setting up examples that needed a quick and easy setup for signal handling, providing a message-based solution around the simple-signal library. A more robust (if also more verbose) solution is possible when using the signal-hook library.
Similar functionality to signal-msg is provided by the signal-notify and chan-signal libraries (note, though, that the latter is deprecated).)
use signal_msg::{self, SignalReceiver, SignalSender};
fn main() {
let (signal_sender, signal_receiver) = signal_msg::new();
signal_sender.prepare_signals();
println!("Waiting for a signal...");
let sig = signal_receiver.listen();
println!("Got signal: {:?}", sig.unwrap());
}
The project logo is derived from the "signpost" icon in the motorway icon set by Freepik.
Copyright © 2020, Oxur Group
MIT License