PTHREAD_GETNAME_NP(3C) Standard C Library Functions PTHREAD_GETNAME_NP(3C)

pthread_getname_np, pthread_setname_npget or set the name of a thread

#include <pthread.h>

int
pthread_getname_np(pthread_t tid, char *name, size_t len);

int
pthread_setname_np(pthread_t tid, const char *name);

The () and pthread_setname_np() functions, respectively, get and set the names of the thread whose id is given by the tid parameter. For pthread_getname_np(), len indicates the size of name.

Thread names are limited to PTHREAD_MAX_NAMELEN_NP including the terminating NUL. They may only contain printable ASCII characters.

To clear a thread name, call () with NULL.

Unlike some other systems, threads do not inherit the process name by default.

Upon successful completion, the pthread_getname_np() and pthread_setname_np() functions return . Otherwise, an error number is returned to indicate the error. If the thread identified by tid does not have a name set, pthread_getname_np will be set to an empty string (length = 0).

On failure, the contents of the buffer are undefined. Errors from open(2), read(2), or write(2) are possible. In addition, the pthread_getname_np() function will fail with:

The name argument is NULL.
The size of name as given by len was not large enough to contain the name of the thread.
The thread tid was not found.

The pthread_setname_np() function will fail with:

The length of name exceeds the maximum allowed size.
The thread tid was not found.

pthread_attr_getname_np(3c), pthread_create(3c)

August 22, 2018 OmniOS