Skip to content

Commit ca36fe3

Browse files
committed
std::thread: set_name change for solaris/illumos.
truncate down to 32 (31 + 1) for solaris/illumos.
1 parent 3d5528c commit ca36fe3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/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
}
@@ -360,6 +363,8 @@ impl Drop for Thread {
360363
target_os = "tvos",
361364
target_os = "watchos",
362365
target_os = "nto",
366+
target_os = "solaris",
367+
target_os = "illumos",
363368
))]
364369
fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
365370
let mut result = [0; MAX_WITH_NUL];

0 commit comments

Comments
 (0)