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

#374 in Operating systems

Download history 5288/week @ 2024-11-15 6664/week @ 2024-11-22 4229/week @ 2024-11-29 5722/week @ 2024-12-06 8034/week @ 2024-12-13 3877/week @ 2024-12-20 2921/week @ 2024-12-27 4956/week @ 2025-01-03 5064/week @ 2025-01-10 4959/week @ 2025-01-17 5964/week @ 2025-01-24 6404/week @ 2025-01-31 6760/week @ 2025-02-07 4837/week @ 2025-02-14 8231/week @ 2025-02-21 4586/week @ 2025-02-28

25,922 downloads per month
Used in 12 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

~45KB