DCMD_PROC_TIDSTATUS

Get the current status of a thread in the process associated with the file descriptor.

#include <sys/procfs.h>

#define DCMD_PROC_TIDSTATUS32  (__DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 7, procfs_status32))
#define DCMD_PROC_TIDSTATUS64  (__DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 7, procfs_status64))
#define DCMD_PROC_TIDSTATUS    (__DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 7, procfs_status))
Note: The generic command maps onto the 64-bit version, unless you're compiling for a 32-bit architecture and you define WANT_OLD_DEVCTLS before you include <sys/procfs.h>.

The arguments to devctl() are:

Argument Value
filedes A file descriptor for the process.
dcmd DCMD_PROC_TIDSTATUS
dev_data_ptr A pointer to a procfs_status structure
n_bytes sizeof(procfs_status)
dev_info_ptr NULL

This is a short form of using DCMD_PROC_CURTHREAD to set the current thread, then DCMD_PROC_STATUS to get information about that thread, and then restoring the current thread.

The argument is a pointer to a procfs_status structure (see debug_thread_t in <sys/debug.h>), with the required thread ID specified in the tid field. This structure is filled in with the required information on return. For example:

procfs_status my_status;

my_status.tid = 1;
devctl( fd, DCMD_PROC_TIDSTATUS, &my_status, sizeof(my_status),
        NULL);
Note: If the thread that you specified no longer exists, the process manager returns information about the one with the next higher thread ID (in which case the tid member won't be the same as it was before you called the command). If there are no threads with a higher ID, devctl() returns ESRCH.

For more information about the contents of this structure, see Thread information,” earlier in this chapter.