diff options
| author | Jonas Maier <> | 2026-03-05 17:37:52 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-05 17:37:52 +0100 |
| commit | 07c802b93a241d566161d3077b3254df4067fa1e (patch) | |
| tree | ebe370181c9660d3b6657d2de12e5adc3b884946 /src/run | |
| parent | f919c3e5d10db7afe41a14b94b99cd38e44d2720 (diff) | |
| download | pish-07c802b93a241d566161d3077b3254df4067fa1e.tar.gz | |
lots of shenanigans to have proper execve reload
Diffstat (limited to 'src/run')
| -rw-r--r-- | src/run/builtin.rs | 10 | ||||
| -rw-r--r-- | src/run/mod.rs | 5 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/run/builtin.rs b/src/run/builtin.rs index 0f90e51..da6f4f2 100644 --- a/src/run/builtin.rs +++ b/src/run/builtin.rs @@ -43,9 +43,13 @@ impl Builtin for re { session.raw.disable(); match Command::new("cargo").arg("build").status() { Ok(status) if status.success() => { - let _ = Command::new("cargo").arg("run").status(); - session.raw.disable(); - std::process::exit(0); + // build of new shell succeeded + + // unwind the entire stack intentionally to free resources + // the catch handler will check the boolean and execve into + // the new executable + super::RELOAD.store(true, std::sync::atomic::Ordering::SeqCst); + std::panic::resume_unwind(Box::new(42)); } _ => (), } diff --git a/src/run/mod.rs b/src/run/mod.rs index 6484e30..0000547 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -2,12 +2,17 @@ use std::collections::HashMap; use std::fs; use std::os::unix::fs::PermissionsExt; use std::path::PathBuf; +#[cfg(debug_assertions)] +use std::sync::atomic::AtomicBool; use crate::parse::Ast; use crate::*; mod builtin; +#[cfg(debug_assertions)] +pub static RELOAD: AtomicBool = AtomicBool::new(false); + pub fn run(se: &mut Session, cmd: Vec<u8>) { let parsed = parse::do_parse(&cmd); |
