---
name: "PR_SET_PTRACER"
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_PTRACER"
---

# PR\_SET\_PTRACER(2const)

allow processes to ptrace(2) the calling process

## NAME

PR\_SET\_PTRACER - allow processes to [ptrace(2)](/ptrace/2.md) the calling process

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

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

**int prctl(PR\_SET\_PTRACER, long** *pid***);**

## DESCRIPTION

This is meaningful only when the Yama LSM is enabled and in mode 1 ("restricted ptrace", visible via */proc/sys/kernel/yama/ptrace\_scope*).

When a "ptracer process ID" is passed in *pid*, the caller is declaring that the ptracer process can [**ptrace**(2)](/ptrace/2.md) the calling process as if it were a direct process ancestor.

Each **PR\_SET\_PTRACER** operation replaces the previous "ptracer process ID".

Employing **PR\_SET\_PTRACER** with *pid* set to 0 clears the caller's "ptracer process ID". If *pid* is **PR\_SET\_PTRACER\_ANY**, the ptrace restrictions introduced by Yama are effectively disabled for the calling process.

## RETURN VALUE

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

## ERRORS

- **EINVAL**

  *pid* is not 0, **PR\_SET\_PTRACER\_ANY**, nor the PID of an existing process.

## STANDARDS

Linux.

## HISTORY

Linux 3.4.

## SEE ALSO

[**prctl**(2)](/prctl/2.md)

For further information, see the kernel source file *Documentation/admin-guide/LSM/Yama.rst*.
