PTHREAD_SET_NAME_NP(3)

NAME
pthread_set_name_np, pthread_setname_np, pthread_get_name_np, pthread_getname_np - set and get the thread name

LIBRARY
libpthread

SYNOPSIS
#include <pthread.h>
#include <pthread_np.h>
void
pthread_set_name_np(pthread_t tid, const char *name);
int
pthread_setname_np(pthread_t tid, const char *name);
void
pthread_get_name_np(pthread_t tid, char *name, size_t len);
int
pthread_getname_np(pthread_t tid, char *name, size_t len);

DESCRIPTION
The pthread_set_name_np() and pthread_setname_np() functions set the internal name of the thread specified by the tid argument to the string value specified by the name argument.

The pthread_get_name_np() and pthread_getname_np() functions get the internal name of the thread specified by the tid argument and store it in the buffer. If the thread does not exist, the buffer is written as an empty line.

RETURN VALUES
Upon successful completion, pthread_getname_np() and pthread_setname_np() will return 0. Otherwise, an error is returned.

ERRORS
The pthread_getname_np() and pthread_setname_np() functions will fail if

[EFAULT]
    The name parameter is outside the process's allocated address space.

[EINVAL]
    The tid argument specifies an invalid thread.

[ESRCH]
    No thread could be found in the current process corresponding to that specified by the given thread ID tid.

Because of the debugging nature of the pthread_get_name_np and pthread_set_name_np functions, all errors that may appear inside are silently ignored. However, errno may still be set.

SEE ALSO
lwp_setname(2)

STANDARDS
The pthread_set_name_np() and pthread_get_name_np() functions are non-standard extensions. While also non-standard, pthread_setname_np() and pthread_getname_np() are implemented by a larger number of operating systems so they are in fact more portable.

AUTHORS
This manual page was written by Alexey Zelkin <phantom@FreeBSD.org>.