File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
library/std/src/sys/pal/unix Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,9 @@ impl Drop for Thread {
321321pub ( crate ) fn current_os_id ( ) -> Option < u64 > {
322322 // Most Unix platforms have a way to query an integer ID of the current thread, all with
323323 // slightly different spellings.
324+ //
325+ // The OS thread ID is used rather than `pthread_self` so as to match what will be displayed
326+ // for process inspection (debuggers, trace, `top`, etc.).
324327 cfg_if:: cfg_if! {
325328 // Most platforms have a function returning a `pid_t` or int, which is an `i32`.
326329 if #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ] {
@@ -349,6 +352,11 @@ pub(crate) fn current_os_id() -> Option<u64> {
349352 // SAFETY: FFI call with no preconditions.
350353 let id: libc:: lwpid_t = unsafe { libc:: _lwp_self( ) } ;
351354 Some ( id as u64 )
355+ } else if #[ cfg( target_os = "illumos" ) ] {
356+ // On Illumos, the `pthread_t` is the same as the OS thread ID.
357+ // SAFETY: FFI call with no preconditions.
358+ let id: libc:: pthread_t = unsafe { libc:: pthread_self( ) } ;
359+ Some ( id as u64 )
352360 } else if #[ cfg( target_vendor = "apple" ) ] {
353361 // Apple allows querying arbitrary thread IDs, `thread=NULL` queries the current thread.
354362 let mut id = 0u64 ;
You can’t perform that action at this time.
0 commit comments