get or set thread name
char *name, size_t namelen);
const char *name);
system call stores the name of tid, a thread in the
current process, into the buffer name, which must be
of at least namelen bytes long. The buffer should be
large enough to store the thread name and a trailing NUL (typically
MAXCOMLEN+1 bytes). The
system call sets the name of tid to the supplied
name. For both functions, if tid
is zero then the current thread is operated on.
Thread names have no inherent meaning in the system and are
intended for display and debugging only. They are not secret but rather are
visible to other processes using
or kvm_getprocs(3) and in
After execve(2), the name of the process's only thread is reset to the empty string. Similarly, additional threads created with __tfork(3) start with the empty name. After fork(2), the new process's only thread has the same name as the thread that invoked fork(2).
Upon successful completion, the value 0 is returned; otherwise the error number is returned.
setthrname() will succeed unless:
- The name argument points to an invalid address.
getthrname() may return the
- The value of namelen is not large enough to store the thread name and a trailing NUL.
setthrname() may return the following
- The name argument pointed to a string that was too
long. Thread names are limited to
MAXCOMLENcharacters, currently 23.
execve(2), fork(2), sysctl(2), __tfork(3), kvm_getprocs(3), pthread_set_name_np(3)
setthrname() system calls are specific to
pthread_set_name_np(3) operate on the same thread name in a
more portable way.
setthrname() system calls first appeared in