Registry / cli / ctrlc
library3.5.2rscratesunverified

Easy Ctrl-C handler for Rust projects, allowing graceful shutdown on SIGINT.

# Cargo.toml [dependencies] ctrlc = "3.5.2"
INSTALL
IMPORT
SIG · CTRLC
C
ctrlc
clirustv3.5.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

set_handler
use ctrlc::set_handler;

Sets a Ctrl-C handler that prints a message and exits.

use ctrlc::set_handler; fn main() { set_handler(|| { println!("Ctrl-C pressed! Exiting..."); std::process::exit(0); }).expect("Error setting Ctrl-C handler"); loop {} }
Debug
Known issues
gotchaHandler runs in a signal handler context, so it must not allocate or use most standard library features.
fix
Use only simple operations like setting a flag or printing to stderr; consider using `std::sync::atomic` for communication.
affects: >=3.0.0
Upgrade
Version history
3.5.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
22
Resources
ctrlc — cargo add ctrlc · libregistry