Skip to content

Instantly share code, notes, and snippets.

@kracekumar
Created November 13, 2016 06:41
Show Gist options
  • Select an option

  • Save kracekumar/c4012062b73612b3699e1de03774d11e to your computer and use it in GitHub Desktop.

Select an option

Save kracekumar/c4012062b73612b3699e1de03774d11e to your computer and use it in GitHub Desktop.
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