6 stable releases

Uses old Rust 2015

1.1.1 Mar 21, 2018
1.1.0 Nov 11, 2016
1.0.6 Jun 11, 2016
1.0.5 Mar 1, 2016
1.0.4 Dec 4, 2015

#217 in Unix APIs

Download history 1697/week @ 2023-01-19 2026/week @ 2023-01-26 1931/week @ 2023-02-02 1561/week @ 2023-02-09 1993/week @ 2023-02-16 2627/week @ 2023-02-23 1880/week @ 2023-03-02 2218/week @ 2023-03-09 1849/week @ 2023-03-16 2475/week @ 2023-03-23 2447/week @ 2023-03-30 2391/week @ 2023-04-06 2268/week @ 2023-04-13 2611/week @ 2023-04-20 2609/week @ 2023-04-27 1955/week @ 2023-05-04

9,768 downloads per month
Used in 11 crates

MIT license

8KB
159 lines

simple-signal

A simple wrapper for handling Unix process signals.

Example Usage

extern crate simple_signal;

use simple_signal::{self, Signal};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

fn main() {
    let running = Arc::new(AtomicBool::new(true));
    let r = running.clone();
    simple_signal::set_handler(&[Signal::Int, Signal::Term], move |_signals| {
        r.store(false, Ordering::SeqCst);
    });
    println!("Waiting for a signal...");
    while running.load(Ordering::SeqCst) {}
    println!("Got it! Exiting...");
}

Try the example yourself

cargo run --example readme_example

Building

If you're using a nightly compiler, I suggest building with cargo build --features nightly to avoid the dependency on lazy_static. On stable and beta compilers, just run cargo build.


lib.rs:

A simple wrapper for handling Unix process signals.

Dependencies

~42KB