Skip to content

QNX: pass a truncated thread name to the OS #114967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ impl Thread {
}

if let Some(f) = pthread_setname_np.get() {
#[cfg(target_os = "nto")]
let name = truncate_cstr::<{ libc::_NTO_THREAD_NAME_MAX as usize }>(name);

let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
debug_assert_eq!(res, 0);
}
Expand Down Expand Up @@ -290,6 +293,7 @@ impl Drop for Thread {
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "nto",
))]
fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
let mut result = [0; MAX_WITH_NUL];
Expand Down