Skip to main content

Module signals

Module signals 

Source
Expand description

Signal handling for graceful interruption (Phase 10)

This module provides signal handling for Ctrl+C (SIGINT) interruption to allow graceful shutdown and partial result reporting.

§Mitigations

  • A36: No signal handling for graceful interruption
    • Catches SIGINT (Ctrl+C)
    • Allows current file to complete
    • Returns partial results with interrupt metadata

§Example

use tldr_cli::signals::{setup_signal_handler, is_interrupted, InterruptState};

// Set up handler at start of main
let state = setup_signal_handler()?;

// Check periodically in analysis loops
for file in files {
    if is_interrupted() {
        eprintln!("Interrupted. Returning partial results...");
        break;
    }
    process_file(file)?;
}

// Report partial results
if state.was_interrupted() {
    eprintln!("Analyzed {}/{} files before interrupt", state.files_completed(), total);
}

Structs§

InterruptMetadata
Metadata about an interrupted analysis.
InterruptState
State tracking for interruptible operations.

Functions§

is_interrupted
Check if the process has been interrupted.
report_interrupt_status
Report on interrupt status.
reset_interrupted
Reset the interrupted flag.
setup_signal_handler
Set up the signal handler for SIGINT.