Skip to content

Commit

Permalink
Fix current_exe() on DragonFly (again)
Browse files Browse the repository at this point in the history
This is a follow up on [this pull request][1].

Since DragonFly 4.6.1 ([this commit][2]), the "kern.proc.pathname"
sysctl works correctly, i.e. it does not return paths including a ":"
(see [here][3]). Use it and don't try to fix old versions of DragonFly!
There are not many DragonFly installations out there that we can't
control and no one is compiling Rust from source. If someone wants to
run Rust on a pre-4.6.1 DragonFly system, the ports system should
provide a patch.

[1]: #35494
[2]: https://gitweb.dragonflybsd.org/dragonfly.git/commit/726f7ca07e193db73635e9c4e24e40c96087d6d9
[3]: https://gist.github.com/mneumann/a2f6b6a0a03935b561d6185872a4b222
  • Loading branch information
mneumann committed Dec 6, 2016
1 parent d14d74d commit dfd3b90
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/libstd/sys/unix/os.rs
Expand Up @@ -78,7 +78,7 @@ pub fn errno() -> i32 {
static errno: c_int;
}

errno as i32
unsafe { errno as i32 }
}

/// Gets a detailed string description for the given error number.
Expand Down Expand Up @@ -193,7 +193,7 @@ impl StdError for JoinPathsError {
fn description(&self) -> &str { "failed to join paths" }
}

#[cfg(target_os = "freebsd")]
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
pub fn current_exe() -> io::Result<PathBuf> {
unsafe {
let mut mib = [libc::CTL_KERN as c_int,
Expand All @@ -218,11 +218,6 @@ pub fn current_exe() -> io::Result<PathBuf> {
}
}

#[cfg(target_os = "dragonfly")]
pub fn current_exe() -> io::Result<PathBuf> {
::fs::read_link("/proc/curproc/file")
}

#[cfg(target_os = "netbsd")]
pub fn current_exe() -> io::Result<PathBuf> {
::fs::read_link("/proc/curproc/exe")
Expand Down

0 comments on commit dfd3b90

Please sign in to comment.