* chore: update to stable toolchain. apply clippy fixes & rustfmt * Bump MSRV * Try MSRV without the patch version * fix: pin toolchain to MSRV * trying again * fix dead code warning --------- Co-authored-by: Dan Sully <dsully@users.noreply.github.com>
18 lines
563 B
Rust
18 lines
563 B
Rust
//! SIGINT handling in Unix systems.
|
|
use crate::ctrlc::interrupted::set_interrupted;
|
|
use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal};
|
|
|
|
/// Handle SIGINT. Set the interruption flag.
|
|
extern "C" fn handle_sigint(_: i32) {
|
|
set_interrupted();
|
|
}
|
|
|
|
/// Set the necessary signal handlers.
|
|
/// The function panics on failure.
|
|
pub fn set_handler() {
|
|
let sig_action = SigAction::new(SigHandler::Handler(handle_sigint), SaFlags::empty(), SigSet::empty());
|
|
unsafe {
|
|
sigaction(Signal::SIGINT, &sig_action).unwrap();
|
|
}
|
|
}
|