Skip to content

Commit c288ae3

Browse files
committed
Fix Thread::set_name on cygwin
1 parent 1f27619 commit c288ae3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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)