PTHREAD_GETNAME_NP(3C) | Standard C Library Functions | PTHREAD_GETNAME_NP(3C) |
pthread_getname_np
,
pthread_setname_np
— get 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
pthread_getname_np
()
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
pthread_setname_np
()
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
0. 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:
EINVAL
ERANGE
ESRCH
The pthread_setname_np
() function will
fail with:
August 22, 2018 | OmniOS |