handle SIGQUIT (#5744)

* handle sigquit

* fix clippy
This commit is contained in:
WindSoilder
2022-06-09 20:08:15 +08:00
committed by GitHub
parent 5bae7e56ef
commit 2e0b964d5b
5 changed files with 35 additions and 1 deletions

View File

@ -75,6 +75,8 @@ pub struct EngineState {
pub config: Config,
#[cfg(feature = "plugin")]
pub plugin_signatures: Option<PathBuf>,
#[cfg(not(windows))]
sig_quit: Option<Arc<AtomicBool>>,
}
pub const NU_VARIABLE_ID: usize = 0;
@ -106,6 +108,8 @@ impl EngineState {
config: Config::default(),
#[cfg(feature = "plugin")]
plugin_signatures: None,
#[cfg(not(windows))]
sig_quit: None,
}
}
@ -713,6 +717,21 @@ impl EngineState {
self.num_files() - 1
}
#[cfg(not(windows))]
pub fn get_sig_quit(&self) -> &Option<Arc<AtomicBool>> {
&self.sig_quit
}
#[cfg(windows)]
pub fn get_sig_quit(&self) -> &Option<Arc<AtomicBool>> {
&None
}
#[cfg(not(windows))]
pub fn set_sig_quit(&mut self, sig_quit: Arc<AtomicBool>) {
self.sig_quit = Some(sig_quit)
}
}
/// A temporary extension to the global state. This handles bridging between the global state and the