mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-10 17:07:36 +00:00
os current_exe using same approach as linux to get always the full absolute path
but in case of failure (e.g. prcfs not mounted) still using getexecname.
This commit is contained in:
parent
b289bb7fdf
commit
cb4519e59c
@ -368,6 +368,9 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||||||
|
|
||||||
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
|
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
|
||||||
pub fn current_exe() -> io::Result<PathBuf> {
|
pub fn current_exe() -> io::Result<PathBuf> {
|
||||||
|
if let Ok(path) = crate::fs::read_link("/proc/self/path/a.out") {
|
||||||
|
Ok(path)
|
||||||
|
} else {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn getexecname() -> *const c_char;
|
fn getexecname() -> *const c_char;
|
||||||
}
|
}
|
||||||
@ -384,6 +387,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||||||
if filename[0] == b'/' { Ok(path) } else { getcwd().map(|cwd| cwd.join(path)) }
|
if filename[0] == b'/' { Ok(path) } else { getcwd().map(|cwd| cwd.join(path)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "haiku")]
|
#[cfg(target_os = "haiku")]
|
||||||
|
Loading…
Reference in New Issue
Block a user