| 1 |
.\" Copyright, Guillem Jover <[email protected]> |
| 2 |
.\" Copyright 2006-2015, Michael Kerrisk <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH PR_SET_NAME 2const 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
PR_SET_NAME, |
| 10 |
PR_GET_NAME |
| 11 |
\- |
| 12 |
operations on a process or thread |
| 13 |
.SH LIBRARY |
| 14 |
Standard C library |
| 15 |
.RI ( libc ,\~ \-lc ) |
| 16 |
.SH SYNOPSIS |
| 17 |
.nf |
| 18 |
.BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */" |
| 19 |
.B #include <sys/prctl.h> |
| 20 |
.P |
| 21 |
.BI "int prctl(PR_SET_NAME, const char *" name ); |
| 22 |
.BI "int prctl(PR_GET_NAME, char " name [16]); |
| 23 |
.fi |
| 24 |
.SH DESCRIPTION |
| 25 |
.TP |
| 26 |
.B PR_SET_NAME |
| 27 |
Set the name of the calling thread, |
| 28 |
using the value in the location pointed to by |
| 29 |
.IR name . |
| 30 |
.IP |
| 31 |
The name can be up to 16 bytes long, |
| 32 |
.\" TASK_COMM_LEN in include/linux/sched.h |
| 33 |
including the terminating null byte. |
| 34 |
If the length of the string, including the terminating null byte, |
| 35 |
exceeds 16 bytes, the string is silently truncated. |
| 36 |
.TP |
| 37 |
.BR PR_GET_NAME " (since Linux 2.6.11)" |
| 38 |
Return the name of the calling thread, |
| 39 |
in the buffer pointed to by |
| 40 |
.IR name . |
| 41 |
The returned string will be null-terminated. |
| 42 |
.P |
| 43 |
This is the same attribute that can be set via |
| 44 |
.BR pthread_setname_np (3) |
| 45 |
and retrieved using |
| 46 |
.BR pthread_getname_np (3). |
| 47 |
.SH RETURN VALUE |
| 48 |
On success, |
| 49 |
0 is returned. |
| 50 |
On error, \-1 is returned, and |
| 51 |
.I errno |
| 52 |
is set to indicate the error. |
| 53 |
.SH ERRORS |
| 54 |
.TP |
| 55 |
.B EFAULT |
| 56 |
.I name |
| 57 |
is an invalid address. |
| 58 |
.SH FILES |
| 59 |
.TP |
| 60 |
.IR /proc/self/task/\: tid /\:comm |
| 61 |
The attribute is likewise accessible via this file |
| 62 |
(see |
| 63 |
.BR proc_pid_comm (5)), |
| 64 |
where |
| 65 |
.I tid |
| 66 |
is the thread ID of the calling thread, as returned by |
| 67 |
.BR gettid (2). |
| 68 |
.SH STANDARDS |
| 69 |
Linux. |
| 70 |
.SH HISTORY |
| 71 |
.TP |
| 72 |
.B PR_SET_NAME |
| 73 |
Linux 2.6.9. |
| 74 |
.TP |
| 75 |
.B PR_GET_NAME |
| 76 |
Linux 2.6.11. |
| 77 |
.SH SEE ALSO |
| 78 |
.BR prctl (2), |
| 79 |
.BR pthread_setname_np (3), |
| 80 |
.BR pthread_getname_np (3), |
| 81 |
.BR proc_pid_comm (5) |