THR_SET_NAME(2)

πŸ’– THR_SET_NAME(2) πŸ’–

okay bestie, so this is a system call β€” from the System Calls Manual β€” and it's literally called thr_set_name. Yes, that's the whole vibe: it sets the user-visible thread name. πŸŽ€


✨ NAME ✨

thr_set_name β€” set user-visible thread name 🏷️


πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) 🫢


🌸 SYNOPSIS 🌸

#include <sys/thr.h>

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

πŸ’… DESCRIPTION πŸ’…

so basically, the thr_set_name() system call sets the user-visible name for the thread with the identifier id β€” in the current process, no cap β€” to the NUL-terminated string name. ✨

and listen. the name gets silently truncated to fit into a buffer of MAXCOMLEN + 1 bytes. no error, no warning, no drama β€” it just gets cut off. πŸ’€ so if you name your thread something iconic and long, only the beginning survives. keep that in mind, bestie.

where does the name show up, you ask? literally everywhere, it's giving main character energy: πŸ‘‘

  • the output of ps(1) and top(1) commands
  • the kernel debuggers πŸ›
  • the kernel tracing facility outputs
  • userland debuggers and program core files β€” as notes

πŸ”₯ RETURN VALUES πŸ”₯

if it slays: thr_set_name() returns zero. πŸŽ‰

if it does not slay: -1 is returned, and errno is set to indicate the error. 😭


🚨 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 πŸ‘€

ps(1), thr_exit(2), thr_kill(2), thr_kill2(2), thr_new(2), thr_self(2), _umtx_op(2), pthread_set_name_np(3), ddb(4), ktr(9) πŸ¦‹


⭐ STANDARDS ⭐

the thr_set_name() system call is non-standard β€” periodt. it's used by the 1:1 Threading Library (libthr, -lthr). 🌈


and that's the whole page, bestie!! πŸ’œ this one shipped from Debian, dated December 2, 2016 β€” so like, a vintage icon at this point. go name ur threads something cute πŸŽ€βœ¨

πŸ“¦ where this page comes from