Open
Description
Calling current_exe()
on linux after the original executable has been deleted or replaced results in an invalid path being returned.
fn main() {
// current_exe = /path/to/executable
remove_file(current_exe().unwrap()).ok();
println!("{:?}", current_exe());
}
Output
Ok("/path/to/executable (deleted)")
Desired behavior
While it is the correct behavior of the underlying /proc/self/exe
to append the string (deleted)
to the original pathname the result is not a valid path and might even end up pointing to a completely different file.
I would either expect the docs to explicitly mention this behavior or classify it as an error and return io::ErrorKind::NotFound
accordingly.
Meta
rustc --version --verbose
:
rustc 1.41.0 (5e1a79984 2020-01-27)
binary: rustc
commit-hash: 5e1a799842ba6ed4a57e91f7ab9435947482f7d8
commit-date: 2020-01-27
host: x86_64-unknown-linux-gnu
release: 1.41.0
LLVM version: 9.0
I would gladly claim this issue if you agree to it.