From 9c8707fc444c0f06d5f08236dbad86e4896b3448 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 15 Feb 2021 23:51:35 +0000 Subject: [PATCH] added more graceful interrupt handler --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ca92005..4de02cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,7 +47,12 @@ async fn main() -> eyre::Result<()> { .wrap_err(eyre!("Invalid config")) .with_suggestion(|| "Try running `--help`")?); - let graph = work::work_on_all(state).await; + let graph = tokio::select!{ + x = work::work_on_all(state) => {x} + _ = tokio::signal::ctrl_c() => { + return Err(eyre!("Interrupt signalled, exiting")); + } + }; let mut graph = graph.into_hierarchical(); graph.compute_recursive_sizes();