mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 14:51:01 +02:00
Simplify SIGQUIT
handling (#11381)
# 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.
This commit is contained in:
@ -32,7 +32,7 @@ use nu_protocol::{
|
||||
use nu_std::load_standard_library;
|
||||
use nu_utils::utils::perf;
|
||||
use run::{run_commands, run_file, run_repl};
|
||||
use signals::{ctrlc_protection, sigquit_protection};
|
||||
use signals::ctrlc_protection;
|
||||
use std::{
|
||||
io::BufReader,
|
||||
str::FromStr,
|
||||
@ -78,7 +78,6 @@ fn main() -> Result<()> {
|
||||
let ctrlc = Arc::new(AtomicBool::new(false));
|
||||
// TODO: make this conditional in the future
|
||||
ctrlc_protection(&mut engine_state, &ctrlc);
|
||||
sigquit_protection(&mut engine_state);
|
||||
|
||||
// Begin: Default NU_LIB_DIRS, NU_PLUGIN_DIRS
|
||||
// Set default NU_LIB_DIRS and NU_PLUGIN_DIRS here before the env.nu is processed. If
|
||||
|
@ -16,14 +16,3 @@ pub(crate) fn ctrlc_protection(engine_state: &mut EngineState, ctrlc: &Arc<Atomi
|
||||
|
||||
engine_state.ctrlc = Some(engine_state_ctrlc);
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub(crate) fn sigquit_protection(engine_state: &mut EngineState) {
|
||||
use signal_hook::consts::SIGQUIT;
|
||||
let sig_quit = Arc::new(AtomicBool::new(false));
|
||||
signal_hook::flag::register(SIGQUIT, sig_quit.clone()).expect("Error setting SIGQUIT flag");
|
||||
engine_state.set_sig_quit(sig_quit);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub(crate) fn sigquit_protection(_engine_state: &mut EngineState) {}
|
||||
|
@ -30,7 +30,8 @@ pub(crate) fn acquire_terminal(interactive: bool) {
|
||||
std::process::exit(1);
|
||||
};
|
||||
|
||||
// SIGINT and SIGQUIT have special handling
|
||||
// SIGINT has special handling
|
||||
signal(Signal::SIGQUIT, SigHandler::SigIgn).expect("signal ignore");
|
||||
signal(Signal::SIGTSTP, SigHandler::SigIgn).expect("signal ignore");
|
||||
signal(Signal::SIGTTIN, SigHandler::SigIgn).expect("signal ignore");
|
||||
signal(Signal::SIGTTOU, SigHandler::SigIgn).expect("signal ignore");
|
||||
|
Reference in New Issue
Block a user