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§
- Interrupt
Metadata - Metadata about an interrupted analysis.
- Interrupt
State - 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.