pthread_setname_np, pthread_getname_np - set and get the thread name
#include <pthread.h> int pthread_setname_np(pthread_t t, const char *name ); int pthread_getname_np(pthread_t t, char *buf , size_t len);
The pthread_setname_np() function associates a name with a thread t. The thread name is a string of length 31 bytes or less, UTF-8 encoded. If the length of name is greater than 31, the excess bytes are silently ignored.
The pthread_getname_np() function returns the name of the specified thread t in buf. At most, len-1 non-null characters are copied into buf. The returned thread name will be null-terminated.
If successful, the pthread_setname_np() and pthread_getname_np() functions return 0. Otherwise, an error number is returned to indicate the error. It is not an error for the target thread to be a zombie thread.
The pthread_setname_np() and pthread_getname_np() function will fail if:
The value specified by thread does not refer to an existing thread.
The pthread_getname_np() function will fail if:
buf is NULL.
See attributes(7) for descriptions of the following attributes:
|
pthread_attr_init(3C), pthread_attr_setname_np(3C), attributes(7), standards(7), threads(7)