Skip to content

Commit 5dc9079

Browse files
Rollup merge of rust-lang#123323 - devnexen:thread_set_name_solaris_fix, r=workingjubilee
std::thread: set_name change for solaris/illumos. truncate down to 32 (31 + 1) for solaris/illumos.
2 parents 248dae8 + eb67e0d commit 5dc9079

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: std/src/sys/pal/unix/thread.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ impl Thread {
182182

183183
if let Some(f) = pthread_setname_np.get() {
184184
#[cfg(target_os = "nto")]
185-
let name = truncate_cstr::<{ libc::_NTO_THREAD_NAME_MAX as usize }>(name);
185+
const THREAD_NAME_MAX: usize = libc::_NTO_THREAD_NAME_MAX as usize;
186+
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
187+
const THREAD_NAME_MAX: usize = 32;
186188

189+
let name = truncate_cstr::<{ THREAD_NAME_MAX }>(name);
187190
let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
188191
debug_assert_eq!(res, 0);
189192
}
@@ -368,6 +371,8 @@ impl Drop for Thread {
368371
target_os = "tvos",
369372
target_os = "watchos",
370373
target_os = "nto",
374+
target_os = "solaris",
375+
target_os = "illumos",
371376
))]
372377
fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
373378
let mut result = [0; MAX_WITH_NUL];

0 commit comments

Comments
 (0)