use signal_hook::{consts::signal::SIGUSR2, iterator::Signals};
pub fn should_stop() -> bool {
return std::env::var("RSPACK_DEBUG_STOP").is_ok();
}
pub fn wait_for_enter(phase: &str) {
if !should_stop() {
return;
}
println!(
"Waiting in phase {} with pid={}, Press Enter to continue.",
phase,
std::process::id()
);
let mut s = String::new();
let _ = std::io::stdin().read_line(&mut s);
}
pub fn wait_for_signal(phase: &str) {
if !should_stop() {
return;
}
println!(
"Waiting in phase {}, run `kill -SIGUSR2 {}` to continue.",
phase,
std::process::id()
);
let mut signal = Signals::new(&[SIGUSR2]).expect("Failed to create signal handler");
for sig in signal.forever() {
println!("Received signal: {:?}", sig);
break;
}
}