I am writing a Rust program that does an action every 2 seconds. The program also uses the ctrlc
crate to handle interrupts. However, in some cases, I have to wait up to 2 secs when killing the process. I am using the default std::thread::sleep
function, which I seemingly cannot interrupt.
Here comes my question. Is it possible for me to make my program sleep in an interruptible way? In other words, does Rust have a default feature for interrupting a sleeping program? I know that C automatically interrupts any sleep function when the SIGINT signal is received.
ctrlc
handler does not callstd::process::exit
– Bussey