Sleep while waiting for SIGINT

pull/10/head
Alessandro Decina 3 years ago
parent 78aad8a58d
commit 7baf4f5688

@ -23,6 +23,8 @@ use std::{
convert::{TryFrom,TryInto}, convert::{TryFrom,TryInto},
sync::Arc, sync::Arc,
sync::atomic::{AtomicBool, Ordering}, sync::atomic::{AtomicBool, Ordering},
thread,
time::Duration,
}; };
use structopt::StructOpt; use structopt::StructOpt;
@ -99,7 +101,9 @@ fn try_main() -> Result<(), anyhow::Error> {
}).expect("Error setting Ctrl-C handler"); }).expect("Error setting Ctrl-C handler");
println!("Waiting for Ctrl-C..."); println!("Waiting for Ctrl-C...");
while running.load(Ordering::SeqCst) {} while running.load(Ordering::SeqCst) {
thread::sleep(Duration::from_millis(500))
}
println!("Exiting..."); println!("Exiting...");
Ok(()) Ok(())

Loading…
Cancel
Save