Created
February 7, 2014 07:19
-
-
Save wbthomason/8858520 to your computer and use it in GitHub Desktop.
A fixed version of some example Rust code showing simple signal handling.
This file contains hidden or 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
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