pthread_attr_setname_np, pthread_attr_getname_np - set and get the thread name
#include <pthread.h>
int pthread_attr_setname_np( pthread_attr_t *attr, const char *name);
int pthread_attr_getname_np( pthread_attr_t *attr, char *buf, size_t len);
The pthread_attr_setname_np() and pthread_attr_getname_np () functions are used to set and get the threadname attribute in the attr object. The default value for this attribute is NULL. The maximum length of the threadname attribute is 31 bytes, UTF-8 encoded.
For pthread_attr_setname_np(), if the length of the name is greater than 31, the excess bytes are silently ignored. For pthread_attr_getname_np(), at most len-1 non-null characters are copied into buf. The returned thread name will be null-terminated.
Upon successful completion, these functions return a 0; otherwise, an error number is returned to indicate the error.
The pthread_attr_setname_np() function will fail if:
attr is NULL.
The pthread_attr_getname_np() function may fail if:
attr or buf is NULL.
See attributes(5) for descriptions of the following attributes:
|
pthread_attr_init(3C), pthread_setname_np(3C), threads(5), attributes(5)