Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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