Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 927cc54

Browse files
authoredMar 23, 2025
Unrolled build for rust-lang#138765
Rollup merge of rust-lang#138765 - Berrysoft:cygwin-thread-name, r=joboet Fix Thread::set_name on cygwin Just like Linux, Cygwin also sets a limitation to thread name. https://github.com/cygwin/cygwin/blob/8e50c7af7c49819245739d6f626f6fecc394ef7f/winsup/cygwin/thread.cc#L3175
2 parents b48576b + e5fc7d6 commit 927cc54

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎library/std/src/sys/pal/unix/thread.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ impl Thread {
143143
pub fn set_name(name: &CStr) {
144144
unsafe {
145145
cfg_if::cfg_if! {
146-
if #[cfg(target_os = "linux")] {
147-
// Linux limits the allowed length of the name.
146+
if #[cfg(any(target_os = "linux", target_os = "cygwin"))] {
147+
// Linux and Cygwin limits the allowed length of the name.
148148
const TASK_COMM_LEN: usize = 16;
149149
let name = truncate_cstr::<{ TASK_COMM_LEN }>(name);
150150
} else {
@@ -346,6 +346,7 @@ impl Drop for Thread {
346346
target_os = "solaris",
347347
target_os = "illumos",
348348
target_os = "vxworks",
349+
target_os = "cygwin",
349350
target_vendor = "apple",
350351
))]
351352
fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {

0 commit comments

Comments
 (0)
Failed to load comments.