init_ctrlc

Function init_ctrlc 

Source
pub fn init_ctrlc() -> Result<()>
Expand description

Initializes the SIGINT (Ctrl-C) signal handler.

This function installs a minimal, signal-safe handler for SIGINT. Once installed, any incoming Ctrl-C will set an internal flag, which can later be queried via is_ctrlc_received().

This function may be called multiple times; the signal handler will only be installed once. Repeated calls are safe and have no additional effect.

§Note

Use either this function OR init_ctrlc_with_print(), not both.

§Errors

Returns an Err if the underlying system call (sigaction) fails during handler installation. This typically indicates a low-level OS error or permission issue.

§Examples

ctrlc_tiny::init_ctrlc()?;
while !ctrlc_tiny::is_ctrlc_received() {
    // Do work here
}