Created
November 13, 2016 06:41
-
-
Save kracekumar/c4012062b73612b3699e1de03774d11e to your computer and use it in GitHub Desktop.
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
fn main() { | |
let signal = chan_signal::notify(&[Signal::INT, Signal::TERM]); | |
let (sdone, rdone) = chan::sync(0); | |
thread::spawn(move || run(sdone)); // run function will be killed as soon interrupt is received. | |
chan_select! { | |
signal.recv() -> signal => { | |
println!("received signal: {:?}", signal) | |
}, | |
rdone.recv() => { | |
println!("Program completed normally."); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment