Skip to content

Instantly share code, notes, and snippets.

@agatan
Created July 10, 2017 13:27
Show Gist options
  • Save agatan/f0fd4c3bfbdc8d408d4750b78f22d8bc to your computer and use it in GitHub Desktop.
Save agatan/f0fd4c3bfbdc8d408d4750b78f22d8bc to your computer and use it in GitHub Desktop.
Use signal_notify with threads
extern crate signal_notify;
use signal_notify::{notify, Signal};
use std::thread;
fn main() {
let rx = notify(&[Signal::INT]);
thread::spawn(|| {
loop {
thread::sleep(::std::time::Duration::from_secs(10));
}
});
for sig in rx.iter() {
println!("{:?}", sig);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment