Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: July 2017
 
 

pthread_attr_setname_np (3C)

Name

pthread_attr_setname_np, pthread_attr_getname_np - set and get the thread name

Synopsis

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

Description

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.

Return Values

Upon successful completion, these functions return a 0; otherwise, an error number is returned to indicate the error.

Errors

The pthread_attr_setname_np() function will fail if:

EINVAL

attr is NULL.

The pthread_attr_getname_np() function may fail if:

EINVAL

attr or buf is NULL.

Attributes

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

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

See Also

pthread_attr_init(3C), pthread_setname_np(3C), threads(5), attributes(5)