prctl(2)

prctl(2) ๐Ÿ’…

okay bestie, pull up a chair, we're in the System Calls Manual now and this one is a whole vibe. prctl() is the "one syscall to rule them all" situation โ€” it's a giant grab-bag of process-and-thread operations all crammed into a single entry point. no cap, it's giving "swiss army knife that also does your taxes." ๐Ÿ”ฅ


NAME โœจ

prctl โ€” 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(int op, ...);

DESCRIPTION ๐ŸŒธ

so basically: prctl() manipulates various aspects of the behavior of the calling thread or process. that's the whole assignment, and it is so much. ๐Ÿ’€

you call prctl() with a first argument that describes what you want to do, and then further arguments whose significance depends entirely on that first one. so like, the first arg is the main character and everyone else is just supporting cast. main character energy fr fr.

the first argument can be any one of these icons ๐Ÿ‘‘:

  • PR_CAP_AMBIENT
  • PR_CAPBSET_READ
  • PR_CAPBSET_DROP
  • PR_SET_CHILD_SUBREAPER
  • PR_GET_CHILD_SUBREAPER
  • PR_SET_DUMPABLE
  • PR_GET_DUMPABLE
  • PR_SET_ENDIAN
  • PR_GET_ENDIAN
  • PR_SET_FP_MODE
  • PR_GET_FP_MODE
  • PR_SET_FPEMU
  • PR_GET_FPEMU
  • PR_SET_FPEXC
  • PR_GET_FPEXC
  • PR_SET_IO_FLUSHER
  • PR_GET_IO_FLUSHER
  • PR_SET_KEEPCAPS
  • PR_GET_KEEPCAPS
  • PR_MCE_KILL
  • PR_MCE_KILL_GET
  • PR_SET_MM
  • PR_SET_VMA
  • PR_MPX_ENABLE_MANAGEMENT
  • PR_MPX_DISABLE_MANAGEMENT
  • PR_SET_NAME
  • PR_GET_NAME
  • PR_SET_NO_NEW_PRIVS
  • PR_GET_NO_NEW_PRIVS
  • PR_PAC_RESET_KEYS
  • PR_SET_PDEATHSIG
  • PR_GET_PDEATHSIG
  • PR_SET_PTRACER
  • PR_SET_SECCOMP
  • PR_GET_SECCOMP
  • PR_SET_SECUREBITS
  • PR_GET_SECUREBITS
  • PR_GET_SPECULATION_CTRL
  • PR_SET_SPECULATION_CTRL
  • PR_SVE_SET_VL
  • PR_SVE_GET_VL
  • PR_SET_SYSCALL_USER_DISPATCH
  • PR_SET_TAGGED_ADDR_CTRL
  • PR_GET_TAGGED_ADDR_CTRL
  • PR_TASK_PERF_EVENTS_DISABLE
  • PR_TASK_PERF_EVENTS_ENABLE
  • PR_SET_THP_DISABLE
  • PR_GET_THP_DISABLE
  • PR_GET_TID_ADDRESS
  • PR_SET_TIMERSLACK
  • PR_GET_TIMERSLACK
  • PR_SET_TIMING
  • PR_GET_TIMING
  • PR_SET_TSC
  • PR_GET_TSC
  • PR_SET_UNALIGN
  • PR_GET_UNALIGN
  • PR_GET_AUXV
  • PR_SET_MDWE
  • PR_GET_MDWE
  • PR_RISCV_SET_ICACHE_FLUSH_CTX
  • PR_FUTEX_HASH

like. sixty-three vibes. pick one. ๐Ÿซถ


RETURN VALUE ๐ŸŒˆ

  • on success, a nonnegative value comes back ๐Ÿ’–
  • on error, -1 comes back, and errno gets set to indicate the error ๐Ÿ˜ญ

ERRORS โญ

  • EINVAL โ€” the value of op is not recognized, or not supported on this system.
  • EINVAL โ€” an unused argument is nonzero.
๐Ÿ™ˆ yes, that's two separate EINVAL situations, and yes, they're listed separately in the original. we don't flatten lore in this house.

VERSIONS ๐Ÿงš

IRIX has a prctl() system call too โ€” and fun fact, it was also introduced in Linux 2.1.44 as irix_prctl on the MIPS architecture ๐Ÿ“ โ€” with prototype:

ptrdiff_t prctl(int op, int arg2, int arg3);

and operations to get the maximum number of processes per user, get the maximum number of processors the calling process can use, find out whether a specified process is currently blocked, get or set the maximum stack size, and so on. the and-so-on is doing so much heavy lifting there bestie ๐Ÿ’€


STANDARDS ๐Ÿฆ‹

Linux.


HISTORY ๐ŸŽ€

Linux 2.1.57, glibc 2.0.6


CAVEATS โš ๏ธ

listen. listen. this part matters. ๐Ÿ‘‘

the prototype of the libc wrapper uses a variadic argument list. that makes it necessary to pass the arguments with the right width. when you're passing numeric constants, like 0, use a suffix: 0L. do it. don't be cute about it. ๐Ÿ’…

careless use of some prctl() operations can confuse the user-space run-time environment, so these operations should be used with care. like, genuinely. be careful. this is not a drill. ๐Ÿ˜ญ


SEE ALSO โœจ

signal(2), PR_CAP_AMBIENT(2const), PR_CAPBSET_READ(2const), PR_CAPBSET_DROP(2const), PR_SET_CHILD_SUBREAPER(2const), PR_GET_CHILD_SUBREAPER(2const), PR_SET_DUMPABLE(2const), PR_GET_DUMPABLE(2const), PR_SET_ENDIAN(2const), PR_GET_ENDIAN(2const), PR_SET_FP_MODE(2const), PR_GET_FP_MODE(2const), PR_SET_FPEMU(2const), PR_GET_FPEMU(2const), PR_SET_FPEXC(2const), PR_GET_FPEXC(2const), PR_SET_IO_FLUSHER(2const), PR_GET_IO_FLUSHER(2const), PR_SET_KEEPCAPS(2const), PR_GET_KEEPCAPS(2const), PR_MCE_KILL(2const), PR_MCE_KILL_GET(2const), PR_SET_MM(2const), PR_SET_VMA(2const), PR_MPX_ENABLE_MANAGEMENT(2const), PR_MPX_DISABLE_MANAGEMENT(2const), PR_SET_NAME(2const), PR_GET_NAME(2const), PR_SET_NO_NEW_PRIVS(2const), PR_GET_NO_NEW_PRIVS(2const), PR_PAC_RESET_KEYS(2const), PR_SET_PDEATHSIG(2const), PR_GET_PDEATHSIG(2const), PR_SET_PTRACER(2const), PR_SET_SECCOMP(2const), PR_GET_SECCOMP(2const), PR_SET_SECUREBITS(2const), PR_GET_SECUREBITS(2const), PR_SET_SPECULATION_CTRL(2const), PR_GET_SPECULATION_CTRL(2const), PR_SVE_SET_VL(2const), PR_SVE_GET_VL(2const), PR_SET_SYSCALL_USER_DISPATCH(2const), PR_SET_TAGGED_ADDR_CTRL(2const), PR_GET_TAGGED_ADDR_CTRL(2const), PR_TASK_PERF_EVENTS_DISABLE(2const), PR_TASK_PERF_EVENTS_ENABLE(2const), PR_SET_THP_DISABLE(2const), PR_GET_THP_DISABLE(2const), PR_GET_TID_ADDRESS(2const), PR_SET_TIMERSLACK(2const), PR_GET_TIMERSLACK(2const), PR_SET_TIMING(2const), PR_GET_TIMING(2const), PR_SET_TSC(2const), PR_GET_TSC(2const), PR_SET_UNALIGN(2const), PR_GET_UNALIGN(2const), PR_GET_AUXV(2const), PR_SET_MDWE(2const), PR_GET_MDWE(2const), PR_RISCV_SET_ICACHE_FLUSH_CTX(2const), PR_FUTEX_HASH(2const), core(5)


and that's the whole page bestie, you ate that ๐Ÿซถ this one came from Linux man-pages 6.20, dated 2026-02-08, and it lives in the prctl(2) slot of the System Calls Manual. go forth and pass your arguments with the right width. periodt. ๐Ÿ‘‘๐Ÿ’–

๐Ÿ“ฆ 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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms