THR_SET_NAME(2)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

🌸 NAME 🌸

okay bestie, this is THR_SET_NAME(2), aka the page for thr_set_name β€” the system call that sets the user-visible thread name. slay, let’s get into it πŸ’…

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” yes, that’s the one, periodt.

✨ SYNOPSIS ✨

#include <sys/thr.h>

int
thr_set_name(long id, const char *name);

πŸ’– DESCRIPTION πŸ’–

okay so thr_set_name() is the system call that sets the user-visible name for the thread with the identifier id in the current process to the NUL-terminated string name. cute, right? πŸŽ€

the name will be silently truncated to fit into a buffer of MAXCOMLEN + 1 bytes β€” no warning, no drama, it just gets shortened. lowkey iconic.

and where can you see this thread name? bestie, it shows up in the output of the ps(1) and top(1) commands, in the kernel debuggers and kernel tracing facility outputs, and in userland debuggers and program core files, as notes. literally everywhere the cool kids hang out πŸ¦‹

🌈 RETURN VALUES 🌈

if everything’s chill, thr_set_name() returns 0; otherwise, -1 is returned, and errno is set to indicate the error. no cap.

πŸ’€ ERRORS πŸ’€

the thr_set_name() system call may return the following errors:

  • [EFAULT] β€” the memory pointed to by the name argument is not valid.
  • [ESRCH] β€” the thread with the identifier id does not exist in the current process.

πŸ¦‹ SEE ALSO πŸ¦‹

πŸ’œ STANDARDS πŸ’œ

thr_set_name() is non-standard and is used by the 1:1 Threading Library (libthr, -lthr). iykyk ✨

⭐ HISTORY ⭐

thr_set_name() first appeared in FreeBSD 5.2. iconic behavior, honestly.


okay bye bestie 🫢 β€” this page is from Debian, dated May 5, 2020, and it’s THR_SET_NAME(2) πŸ’…βœ¨

πŸ“¦ where this page comes from