---
name: "PR_SET_NAME"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/PR_SET_NAME"
---

# PR\_SET\_NAME(2const)

operations on a process or thread

## 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. If the length of the string, including the terminating null byte, exceeds 16 bytes, the string is silently truncated.

- **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.

This is the same attribute that can be set via [**pthread\_setname\_np**(3)](/pthread_setname_np/3.md) and retrieved using [**pthread\_getname\_np**(3)](/pthread_getname_np/3.md).

## RETURN VALUE

On success, 0 is returned. On error, -1 is returned, and *errno* is set to indicate the error.

## ERRORS

- **EFAULT**

  *name* is an invalid address.

## FILES

- */proc/self/task/*tid*/comm*

  The attribute is likewise accessible via this file (see [**proc\_pid\_comm**(5)](/proc_pid_comm/5.md)), where *tid* is the thread ID of the calling thread, as returned by [**gettid**(2)](/gettid/2.md).

## STANDARDS

Linux.

## HISTORY

- **PR\_SET\_NAME**

  Linux 2.6.9.

- **PR\_GET\_NAME**

  Linux 2.6.11.

## SEE ALSO

[**prctl**(2)](/prctl/2.md), [**pthread\_setname\_np**(3)](/pthread_setname_np/3.md), [**pthread\_getname\_np**(3)](/pthread_getname_np/3.md), [**proc\_pid\_comm**(5)](/proc_pid_comm/5.md)
