Skip to content

Instantly share code, notes, and snippets.

@BinRoot
Created September 23, 2013 21:40
Show Gist options
  • Save BinRoot/6677361 to your computer and use it in GitHub Desktop.
Save BinRoot/6677361 to your computer and use it in GitHub Desktop.
Ctrl-C Signal Detection in Rust (does not work!)
use std::libc::c_int;
extern {
fn signal(sig: c_int, handler: &fn(c_int));
}
#[fixed_stack_segment]
fn main() {
unsafe { signal(2, handle); }
loop {}
}
fn handle(param: c_int) {
println("works!");
}
// error message is
// `fatal runtime error: local malloc outside of task`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment