mirror of
https://github.com/nushell/nushell.git
synced 2025-01-27 00:28:41 +01:00
3a050864df
# Description Simplifies `SIGQUIT` protection to a single `signal` ignore system call. # User-Facing Changes `SIGQUIT` is no longer blocked if nushell is in non-interactive mode (signals should not be blocked in non-interactive mode). Also a breaking API change for `nu_protocol`. # Tests + Formatting Should come after #11178 for testing.
19 lines
471 B
Rust
19 lines
471 B
Rust
use std::sync::{
|
|
atomic::{AtomicBool, Ordering},
|
|
Arc,
|
|
};
|
|
|
|
use nu_protocol::engine::EngineState;
|
|
|
|
pub(crate) fn ctrlc_protection(engine_state: &mut EngineState, ctrlc: &Arc<AtomicBool>) {
|
|
let handler_ctrlc = ctrlc.clone();
|
|
let engine_state_ctrlc = ctrlc.clone();
|
|
|
|
ctrlc::set_handler(move || {
|
|
handler_ctrlc.store(true, Ordering::SeqCst);
|
|
})
|
|
.expect("Error setting Ctrl-C handler");
|
|
|
|
engine_state.ctrlc = Some(engine_state_ctrlc);
|
|
}
|