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

#343 in Operating systems

Download history 4588/week @ 2024-02-26 5519/week @ 2024-03-04 5265/week @ 2024-03-11 7862/week @ 2024-03-18 6057/week @ 2024-03-25 4864/week @ 2024-04-01 5404/week @ 2024-04-08 5526/week @ 2024-04-15 4415/week @ 2024-04-22 6171/week @ 2024-04-29 5093/week @ 2024-05-06 7737/week @ 2024-05-13 5445/week @ 2024-05-20 5516/week @ 2024-05-27 5827/week @ 2024-06-03 5561/week @ 2024-06-10

23,045 downloads per month
Used in 11 crates

MIT license

9KB
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

~46KB