mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-11 01:17:39 +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;
|
||||||
}
|
}
|
||||||
@ -385,6 +388,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "haiku")]
|
#[cfg(target_os = "haiku")]
|
||||||
pub fn current_exe() -> io::Result<PathBuf> {
|
pub fn current_exe() -> io::Result<PathBuf> {
|
||||||
|
Loading…
Reference in New Issue
Block a user