Skip to content

Instantly share code, notes, and snippets.

@wbthomason
Created February 7, 2014 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbthomason/8858520 to your computer and use it in GitHub Desktop.
Save wbthomason/8858520 to your computer and use it in GitHub Desktop.
A fixed version of some example Rust code showing simple signal handling.
use std::io::signal::{Listener, Interrupt};
fn main() {
let mut listener = Listener::new();
listener.register(Interrupt);
let listener = listener;
do spawn {
loop {
match listener.port.recv() {
Interrupt => println!("Got Interrupt'ed"),
_ => (),
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment