Skip to main content

install_ctrl_c_handler

Function install_ctrl_c_handler 

Source
pub fn install_ctrl_c_handler() -> Result<Arc<AtomicBool>>
Expand description

Installs a SIGINT (Ctrl-C) handler that flips the returned flag on receipt, and returns a fresh Arc<AtomicBool> initialised to false.

The flag is the one run_capture polls each iteration; flipping it causes the pipeline to terminate with TerminationReason::Signal. On Unix this uses signal-hook (safe, no global state hijack). On Windows the same signal-hook API targets SIGINT via the console-control handler; the call is portable.

Safe to call once per process. A second call adds a second handler that also flips the flag — harmless but redundant. The capture loop already terminates on the first flip.