PR_SET_NAME(2const)

✨ PR_SET_NAME(2const) ✨

okay bestie, so this is a page from section 2const of the Linux manual (the (2const) bit is literally the manual name, iykyk) and it's all about giving your threads cute little names πŸ’–


πŸŽ€ NAME πŸŽ€

PR_SET_NAME, PR_GET_NAME β€” operations on a process or thread

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)

🌸 SYNOPSIS 🌸

#include <linux/prctl.h>  /* Definition of PR_* constants */
#include <sys/prctl.h>

int prctl(PR_SET_NAME, const char *name);
int prctl(PR_GET_NAME, char name[16]);

πŸ’… DESCRIPTION πŸ’…

PR_SET_NAME

Set the name of the calling thread, using the value in the location pointed to by name.

The name can be up to 16 bytes long, including the terminating null byte. And if the length of the string, including the terminating null byte, exceeds 16 bytes? Bestie, the string is silently truncated. No warning, no drama, it just gets cut off. 😭

PR_GET_NAME (since Linux 2.6.11)

Return the name of the calling thread, in the buffer pointed to by name. The returned string will be null-terminated. Slay.

the tea β˜•

This is the same attribute that can be set via pthread_setname_np(3) and retrieved using pthread_getname_np(3). Same vibe, different doorway, fr fr.

πŸ‘‘ RETURN VALUE πŸ‘‘

On success, 0 is returned. On error, -1 is returned, and errno is set to indicate the error. That's it, that's the whole deal ✨

πŸ’€ ERRORS πŸ’€

  • EFAULT β€” name is an invalid address. (Not me passing a bad pointer πŸ™ˆ)

πŸ“ FILES πŸ“

  • /proc/self/task/tid/comm β€” the attribute is likewise accessible via this file (see proc_pid_comm(5)), where tid is the thread ID of the calling thread, as returned by gettid(2).

🌈 STANDARDS 🌈

Linux. That's the standard. Just Linux. πŸ’…

πŸ¦‹ HISTORY πŸ¦‹

  • PR_SET_NAME β€” Linux 2.6.9.
  • PR_GET_NAME β€” Linux 2.6.11.

⭐ SEE ALSO ⭐

prctl(2), pthread_setname_np(3), pthread_getname_np(3), proc_pid_comm(5)


okay that's the whole page bestie, go name some threads, the kernel is literally waiting πŸ’–

mwah πŸ’‹ this was brought to you by Linux man-pages 6.20, dated 2026-02-08 β€” yes it's giving iconic, no cap.

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms