From 092623c66cb22a80395425feb54645548dcd02ac Mon Sep 17 00:00:00 2001 From: Illia Kripaka Date: Tue, 19 May 2026 18:21:59 +0300 Subject: [PATCH 1/2] cli: use thread parking to wait for regtest to finish --- crates/cli/src/commands/regtest.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/cli/src/commands/regtest.rs b/crates/cli/src/commands/regtest.rs index fb7f35c..d9b4c7d 100644 --- a/crates/cli/src/commands/regtest.rs +++ b/crates/cli/src/commands/regtest.rs @@ -1,8 +1,7 @@ -use std::sync::Arc; -use std::sync::atomic::{AtomicBool, Ordering}; - use smplx_regtest::Regtest as RegtestRunner; use smplx_regtest::RegtestConfig; +use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; use crate::commands::error::CommandError; @@ -22,8 +21,11 @@ impl Regtest { let running = Arc::new(AtomicBool::new(true)); let r = running.clone(); + let main_thread = std::thread::current(); + ctrlc::set_handler(move || { r.store(false, Ordering::SeqCst); + main_thread.unpark(); }) .expect("Error setting Ctrl-C handler"); @@ -39,7 +41,9 @@ impl Regtest { println!("Signer: {:?}", signer.get_address()); println!("======================================"); - while running.load(Ordering::SeqCst) {} + while running.load(Ordering::SeqCst) { + std::thread::park(); + } Ok(client.kill()?) } From 017863e57e434c58cf7aa785528b320af4683728 Mon Sep 17 00:00:00 2001 From: Artem Chystiakov <47551140+Arvolear@users.noreply.github.com> Date: Wed, 20 May 2026 15:21:54 +0300 Subject: [PATCH 2/2] Apply suggestion from @Arvolear --- crates/cli/src/commands/regtest.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/commands/regtest.rs b/crates/cli/src/commands/regtest.rs index d9b4c7d..91e45e6 100644 --- a/crates/cli/src/commands/regtest.rs +++ b/crates/cli/src/commands/regtest.rs @@ -1,8 +1,9 @@ -use smplx_regtest::Regtest as RegtestRunner; -use smplx_regtest::RegtestConfig; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; +use smplx_regtest::Regtest as RegtestRunner; +use smplx_regtest::RegtestConfig; + use crate::commands::error::CommandError; pub struct Regtest {}