1 PTHREAD_GETNAME_NP(3C) Standard C Library Functions PTHREAD_GETNAME_NP(3C) 2 3 NAME 4 pthread_getname_np, pthread_setname_np - get or set the name of a thread 5 6 SYNOPSIS 7 #include <pthread.h> 8 9 int 10 pthread_getname_np(pthread_t tid, char *name, size_t len); 11 12 int 13 pthread_setname_np(pthread_t tid, const char *name); 14 15 DESCRIPTION 16 The pthread_getname_np() and pthread_setname_np() functions, 17 respectively, get and set the names of the thread whose id is given by 18 the tid parameter. For pthread_getname_np(), len indicates the size of 19 name. 20 21 Thread names are limited to PTHREAD_MAX_NAMELEN_NP including the 22 terminating NUL. They may only contain printable ASCII characters. 23 24 To clear a thread name, call pthread_setname_np() with NULL. 25 26 Unlike some other systems, threads do not inherit the process name by 27 default. 28 29 RETURN VALUES 30 Upon successful completion, the pthread_getname_np() and 31 pthread_setname_np() functions return 0. Otherwise, an error number is 32 returned to indicate the error. If the thread identified by tid does not 33 have a name set, pthread_getname_np will be set to an empty string 34 (length = 0). 35 36 ERRORS 37 On failure, the contents of the buffer are undefined. Errors from 38 open(2), read(2), or write(2) are possible. In addition, the 39 pthread_getname_np() function will fail with: 40 41 EINVAL The name argument is NULL. 42 43 ERANGE The size of name as given by len was not large enough 44 to contain the name of the thread. 45 46 ESRCH The thread tid was not found. 47 48 The pthread_setname_np() function will fail with: 49 50 ERANGE The length of name exceeds the maximum allowed size. 51 52 ESRCH The thread tid was not found. 53 54 INTERFACE STABILITY 55 Uncommitted 56 57 MT-LEVEL 58 MT-Safe 59 60 SEE ALSO 61 pthread_attr_getname_np(3c), pthread_create(3c) 62 63 illumos August 22, 2018 illumos