mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 17:14:23 +01:00
parent
5bae7e56ef
commit
2e0b964d5b
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2496,6 +2496,7 @@ dependencies = [
|
|||||||
"reedline",
|
"reedline",
|
||||||
"rstest",
|
"rstest",
|
||||||
"serial_test",
|
"serial_test",
|
||||||
|
"signal-hook",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"winres",
|
"winres",
|
||||||
]
|
]
|
||||||
|
@ -60,6 +60,7 @@ is_executable = "1.0.1"
|
|||||||
[target.'cfg(not(target_os = "windows"))'.dependencies]
|
[target.'cfg(not(target_os = "windows"))'.dependencies]
|
||||||
# Our dependencies don't use OpenSSL on Windows
|
# Our dependencies don't use OpenSSL on Windows
|
||||||
openssl = { version = "0.10.38", features = ["vendored"], optional = true }
|
openssl = { version = "0.10.38", features = ["vendored"], optional = true }
|
||||||
|
signal-hook = { version = "0.3.14", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { path="./crates/nu-test-support", version = "0.63.1" }
|
nu-test-support = { path="./crates/nu-test-support", version = "0.63.1" }
|
||||||
@ -118,4 +119,3 @@ debug = false
|
|||||||
[[bin]]
|
[[bin]]
|
||||||
name = "nu"
|
name = "nu"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
@ -113,6 +113,10 @@ pub fn evaluate_repl(
|
|||||||
if let Some(ctrlc) = &mut engine_state.ctrlc {
|
if let Some(ctrlc) = &mut engine_state.ctrlc {
|
||||||
ctrlc.store(false, Ordering::SeqCst);
|
ctrlc.store(false, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
// Reset the SIGQUIT handler
|
||||||
|
if let Some(sig_quit) = engine_state.get_sig_quit() {
|
||||||
|
sig_quit.store(false, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
|
||||||
config = engine_state.get_config();
|
config = engine_state.get_config();
|
||||||
|
|
||||||
|
@ -75,6 +75,8 @@ pub struct EngineState {
|
|||||||
pub config: Config,
|
pub config: Config,
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
pub plugin_signatures: Option<PathBuf>,
|
pub plugin_signatures: Option<PathBuf>,
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
sig_quit: Option<Arc<AtomicBool>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const NU_VARIABLE_ID: usize = 0;
|
pub const NU_VARIABLE_ID: usize = 0;
|
||||||
@ -106,6 +108,8 @@ impl EngineState {
|
|||||||
config: Config::default(),
|
config: Config::default(),
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
plugin_signatures: None,
|
plugin_signatures: None,
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
sig_quit: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,6 +717,21 @@ impl EngineState {
|
|||||||
|
|
||||||
self.num_files() - 1
|
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
|
/// A temporary extension to the global state. This handles bridging between the global state and the
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -73,6 +73,16 @@ fn main() -> Result<()> {
|
|||||||
engine_state.ctrlc = Some(engine_state_ctrlc);
|
engine_state.ctrlc = Some(engine_state_ctrlc);
|
||||||
// End ctrl-c protection section
|
// End ctrl-c protection section
|
||||||
|
|
||||||
|
// SIGQUIT protection section (only works for POSIX system)
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
// End SIGQUIT protection section
|
||||||
|
|
||||||
let mut args_to_nushell = vec![];
|
let mut args_to_nushell = vec![];
|
||||||
let mut script_name = String::new();
|
let mut script_name = String::new();
|
||||||
let mut args_to_script = vec![];
|
let mut args_to_script = vec![];
|
||||||
|
Loading…
Reference in New Issue
Block a user