Created
July 10, 2017 13:27
-
-
Save agatan/f0fd4c3bfbdc8d408d4750b78f22d8bc to your computer and use it in GitHub Desktop.
Use signal_notify with threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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