extern crate closer; use std::thread; use std::time::Duration; fn main() { let closer = closer::Closer::init(); loop { if closer.is_closed() { println!("caught die signal, prepare to exit"); break; } println!("working..."); thread::sleep(Duration::from_secs(2)); } println!("died..."); }