Skip to content

Commit dfd3b90

Browse files
committed
Fix current_exe() on DragonFly (again)
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
1 parent d14d74d commit dfd3b90

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/libstd/sys/unix/os.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn errno() -> i32 {
7878
static errno: c_int;
7979
}
8080

81-
errno as i32
81+
unsafe { errno as i32 }
8282
}
8383

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

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

221-
#[cfg(target_os = "dragonfly")]
222-
pub fn current_exe() -> io::Result<PathBuf> {
223-
::fs::read_link("/proc/curproc/file")
224-
}
225-
226221
#[cfg(target_os = "netbsd")]
227222
pub fn current_exe() -> io::Result<PathBuf> {
228223
::fs::read_link("/proc/curproc/exe")

0 commit comments

Comments
 (0)