From 7baf4f5688a7eb1290506e88186df53acd904243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alessandro=C2=A0Decina?= Date: Fri, 15 Oct 2021 11:07:49 +0000 Subject: [PATCH] Sleep while waiting for SIGINT --- {{project-name}}-ebpf/Cargo.toml | 2 +- {{project-name}}/src/main.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/{{project-name}}-ebpf/Cargo.toml b/{{project-name}}-ebpf/Cargo.toml index 91a4e07..b062455 100644 --- a/{{project-name}}-ebpf/Cargo.toml +++ b/{{project-name}}-ebpf/Cargo.toml @@ -21,4 +21,4 @@ overflow-checks = false panic = "abort" [workspace] -members = [] \ No newline at end of file +members = [] diff --git a/{{project-name}}/src/main.rs b/{{project-name}}/src/main.rs index 0b9f8c6..d31e70e 100644 --- a/{{project-name}}/src/main.rs +++ b/{{project-name}}/src/main.rs @@ -23,6 +23,8 @@ use std::{ convert::{TryFrom,TryInto}, sync::Arc, sync::atomic::{AtomicBool, Ordering}, + thread, + time::Duration, }; use structopt::StructOpt; @@ -99,7 +101,9 @@ fn try_main() -> Result<(), anyhow::Error> { }).expect("Error setting Ctrl-C handler"); println!("Waiting for Ctrl-C..."); - while running.load(Ordering::SeqCst) {} + while running.load(Ordering::SeqCst) { + thread::sleep(Duration::from_millis(500)) + } println!("Exiting..."); Ok(())