PR_SET_PTRACER(2const)

PR_SET_PTRACER2const

Allow processes to ptrace(2) the calling process

Usage

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

int prctl(PR_SET_PTRACER, long pid);

Library

Standard C library (libc, -lc)

Overview

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

Releases

2 releases since Debian 13 (Trixie); the text changed 1 time.

  1. 13
  2. Arch

Standards

Linux.

History

Linux 3.4.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.