mirror of
https://github.com/nushell/nushell.git
synced 2025-01-27 16:48:44 +01:00
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);
|
||
|
}
|