pub fn re_exec_self(override_exe: Option<&Path>) -> Result<Infallible>Expand description
Replace the current process with a fresh invocation of the live binary,
preserving argv, cwd, and env. On Unix this is execv (same PID, old
process image gone). On Windows we spawn a child and exit the parent —
a separate PID, but terminal stdio is shared so the user still sees
one continuous “session” from their perspective.
Important on Windows: After replace_binary renames the running exe
(e.g. atomcode.exe → .atomcode.rolling), std::env::current_exe()
may return the renamed path (.atomcode.rolling) instead of the
original one (atomcode.exe). This is because GetModuleFileNameW
tracks the on-disk filename. If override_exe is provided, it is used
instead of current_exe() — callers should capture the exe path
before calling replace_binary and pass it here.
Never returns on the happy path. An Err return means the handoff
failed (e.g., new binary missing execute bit under unusual filesystem
constraints); caller should surface the error and keep running with
the old binary rather than exiting silently.