pthread_getname_np, pthread_setname_np - get and set the thread name
#include <pthread.h>
int pthread_getname_np(pthread_t thr, char * name, int len);
#if defined(_PTW32_COMPATIBILITY_BSD) ||
defined(_PTW32_COMPATIBILITY_TRU64)
int
pthread_setname_np(pthread_t thr,
const char * name,
void * arg);
#else
int pthread_setname_np(pthread_t thr, const char * name);
#endif
pthread_setname_np() sets the descriptive name of the thread. It takes the following arguments.
#if defined(_PTW32_COMPATIBILITY_BSD)
thr |
The thread whose name will be set. |
name |
The printf(3) format string to be used to construct the name of the thread. The resulting name should be shorter than PTHREAD_MAX_NAMELEN_NP. |
arg |
The printf(3) argument used with name. |
#elif defined(_PTW32_COMPATIBILITY_TRU64)
thr |
The thread whose name will be set. |
name |
The name. |
arg |
Reserved for future use. |
#else
thr |
The thread whose name will be set. |
name |
The name. |
#endif
The string passed as the name argument is copied.
pthread_getname_np() gets the descriptive name of the thread. It takes the following arguments.
thr |
The thread whose descriptive name will be obtained. |
name |
The buffer to be filled with the descriptive name of the thread. |
len |
The size of the buffer name in bytes. |
For the MSVC built library the name is made available for use and display by the MSVS debugger.
These routines return 0 on success or an error code on failure.
The pthread_setname_np function shall fail if:
The value specified by thr does not refer to a valid thread.
The expansion of name with arg has length greater or equal to PTHREAD_MAX_NAMELEN_NP.
The following sections are informative.
None.
In addition to use within applications, when the library is built with MSVC, thread names set via pthread_setname_np will be available for display in the MSVS debugger.
None.
None.
The Base Definitions volume of IEEE Std 1003.1-2001, <pthread.h>