Merge nucleic/sleek-thistle-egret-fyej into dev
This commit is contained in:
@@ -193,9 +193,26 @@ pub fn run() {
|
||||
}
|
||||
};
|
||||
|
||||
run_exit_hook();
|
||||
std::process::exit(i32::from(exit_code));
|
||||
}
|
||||
|
||||
// nash: a hook invoked right before the process exits, so an embedding shell
|
||||
// (nash) can flush its observation event buffer (docs/NASH.md §6.1).
|
||||
static EXIT_HOOK: std::sync::OnceLock<Box<dyn Fn() + Send + Sync>> = std::sync::OnceLock::new();
|
||||
|
||||
/// nash: registers a hook run immediately before the shell process exits.
|
||||
/// May be called at most once; later calls are ignored.
|
||||
pub fn set_exit_hook(hook: Box<dyn Fn() + Send + Sync>) {
|
||||
let _ = EXIT_HOOK.set(hook);
|
||||
}
|
||||
|
||||
fn run_exit_hook() {
|
||||
if let Some(hook) = EXIT_HOOK.get() {
|
||||
hook();
|
||||
}
|
||||
}
|
||||
|
||||
/// Installs panic handlers to report our panic and cleanly exit on panic.
|
||||
fn install_panic_handlers() {
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user