diff options
| author | bors <bors@rust-lang.org> | 2024-06-09 09:37:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-09 09:37:06 +0000 |
| commit | 4f3a276ff1e4e873a739ec34a3ac9e2d365ca2b9 (patch) | |
| tree | de0fd2dfcea3374f20a750d5c6f1ff2f70ef55b9 /library/std/src | |
| parent | b3ca6ee18ad96b45ef403938a58f9fb9d250fbc4 (diff) | |
| parent | 8875fd1ff4df162ef9f387f52edcae9e2a364da8 (diff) | |
| download | rust-4f3a276ff1e4e873a739ec34a3ac9e2d365ca2b9.tar.gz rust-4f3a276ff1e4e873a739ec34a3ac9e2d365ca2b9.zip | |
Auto merge of #126185 - matthiaskrgr:rollup-72dn1s2, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #126137 (tests: Add ui/higher-ranked/trait-bounds/normalize-generic-arg.rs) - #126146 (std::unix::process adding few specific freebsd signals to be able to id.) - #126155 (Remove empty test suite `tests/run-make-fulldeps`) - #126168 (std::unix::os current_exe implementation simplification for haiku.) - #126175 (Use --quiet flag when installing pip dependencies) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/pal/unix/os.rs | 20 | ||||
| -rw-r--r-- | library/std/src/sys/pal/unix/process/process_unix.rs | 4 |
2 files changed, 14 insertions, 10 deletions
diff --git a/library/std/src/sys/pal/unix/os.rs b/library/std/src/sys/pal/unix/os.rs index b5c7d30da7b..ae1e42c419b 100644 --- a/library/std/src/sys/pal/unix/os.rs +++ b/library/std/src/sys/pal/unix/os.rs @@ -462,21 +462,21 @@ pub fn current_exe() -> io::Result<PathBuf> { #[cfg(target_os = "haiku")] pub fn current_exe() -> io::Result<PathBuf> { + let mut name = vec![0; libc::PATH_MAX as usize]; unsafe { - let mut info: mem::MaybeUninit<libc::image_info> = mem::MaybeUninit::uninit(); - let mut cookie: i32 = 0; - // the executable can be found at team id 0 - let result = libc::_get_next_image_info( - 0, - &mut cookie, - info.as_mut_ptr(), - mem::size_of::<libc::image_info>(), + let result = libc::find_path( + std::ptr::null_mut(), + libc::path_base_directory::B_FIND_PATH_IMAGE_PATH, + std::ptr::null_mut(), + name.as_mut_ptr(), + name.len(), ); - if result != 0 { + if result != libc::B_OK { use crate::io::ErrorKind; Err(io::const_io_error!(ErrorKind::Uncategorized, "Error getting executable path")) } else { - let name = CStr::from_ptr((*info.as_ptr()).name.as_ptr()).to_bytes(); + // find_path adds the null terminator. + let name = CStr::from_ptr(name.as_ptr()).to_bytes(); Ok(PathBuf::from(OsStr::from_bytes(name))) } } diff --git a/library/std/src/sys/pal/unix/process/process_unix.rs b/library/std/src/sys/pal/unix/process/process_unix.rs index e2fca8c7e63..72bda90a9ba 100644 --- a/library/std/src/sys/pal/unix/process/process_unix.rs +++ b/library/std/src/sys/pal/unix/process/process_unix.rs @@ -1053,6 +1053,10 @@ fn signal_string(signal: i32) -> &'static str { libc::SIGINFO => " (SIGINFO)", #[cfg(target_os = "hurd")] libc::SIGLOST => " (SIGLOST)", + #[cfg(target_os = "freebsd")] + libc::SIGTHR => " (SIGTHR)", + #[cfg(target_os = "freebsd")] + libc::SIGLIBRT => " (SIGLIBRT)", _ => "", } } |
