Skip to content

Commit ba8b91c

Browse files
committed
Used pthread name functions returning result for FreeBSD and DragonFly
1 parent 45089ec commit ba8b91c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ impl Thread {
142142
}
143143
}
144144

145-
#[cfg(any(
146-
target_os = "freebsd",
147-
target_os = "dragonfly",
148-
target_os = "openbsd",
149-
target_os = "nuttx"
150-
))]
145+
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
146+
pub fn set_name(name: &CStr) {
147+
unsafe {
148+
let res = libc::pthread_setname_np(libc::pthread_self(), name.as_ptr());
149+
// We have no good way of propagating errors here, but in debug-builds let's check that this actually worked.
150+
debug_assert_eq!(res, 0);
151+
}
152+
}
153+
154+
#[cfg(any(target_os = "openbsd", target_os = "nuttx"))]
151155
pub fn set_name(name: &CStr) {
152156
unsafe {
153157
libc::pthread_set_name_np(libc::pthread_self(), name.as_ptr());

0 commit comments

Comments
 (0)