Skip to main content

current_exe_resolved

Function current_exe_resolved 

Source
pub fn current_exe_resolved() -> Result<PathBuf>
Expand description

Resolve the path of the currently-running executable, robust to the Linux kernel’s (deleted) marker.

When a running binary is replaced in place — e.g. cargo install slancha-wire unlinks and recreates ~/.cargo/bin/wire while wire upgrade is still running — the kernel appends a literal (deleted) suffix to /proc/self/exe. That suffix marks the unlinked inode; it is NOT part of the path. std::env::current_exe surfaces it verbatim, and writing it into a systemd ExecStart= / launchd program path corrupts the unit (error: unrecognized subcommand '(deleted)', the unit then flaps forever).

This strips a trailing (deleted) so callers get the real install path, which the in-place replacement has already recreated on disk. Issues #274, #276.