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βnameis an invalid address. (Not me passing a bad pointer π)
π FILES π
/proc/self/task/tid/commβ the attribute is likewise accessible via this file (seeproc_pid_comm(5)), wheretidis the thread ID of the calling thread, as returned bygettid(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
- Copyright 2006-2015, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms