Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Thursday, June 13, 2019
 
 

pthread_getname_np(3C)

Name

pthread_setname_np, pthread_getname_np - set and get the thread name

Synopsis

#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);

Description

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.

Return Values

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.

Errors

The pthread_setname_np() and pthread_getname_np() function will fail if:

ESRCH

The value specified by thread does not refer to an existing thread.

The pthread_getname_np() function will fail if:

EINVAL

buf is NULL.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe

See Also

pthread_attr_init(3C), pthread_attr_setname_np(3C), attributes(7), standards(7), threads(7)