encyclopegia.org

Ptrace

ptrace is a system call found in Unix and several Unix-like operating systems.[src] By using ptrace (an abbreviation of "process trace") one process can control another, enabling the controller to inspect and manipulate the internal state of its target.[src] ptrace is used by debuggers and other code-analysis tools, mostly as aids to software development.[src]

ptrace is a system call found in Unix and several Unix-like operating systems.[src] By using ptrace (an abbreviation of "process trace") one process can control another, enabling the controller to inspect and manipulate the internal state of its target.[src] ptrace is used by debuggers and other code-analysis tools, mostly as aids to software development.[src] ==Uses== ptrace is used by debuggers (such as gdb and dbx), by tracing tools like strace and ltrace, and by code coverage tools.[src] ptrace is also used by specialized programs to patch running programs, to avoid unfixed bugs or to overcome security features.[src] It can further be used as a sandbox and as a run-time environment simulator (like emulating root access for non-root software ).[src] By attaching to another process using the ptrace call, a tool has extensive control over the operation of its target.[src] This includes manipulation of its file descriptors, memory, and registers.[src] It can single-step through the target's code, can observe and intercept system calls and their results, and can manipulate the target's signal handlers and both receive and send signals on its behalf.[src] The ability to write into the target's memory allows not only its data store to be changed, but also the application's own code segment, allowing the controller to install breakpoints and patch the running code of the target.[src] As the ability to inspect and alter another process is very powerful, ptrace can attach only to processes that the owner can send signals to (typically only their own processes); the superuser account can ptrace almost any process (except init on kernels before 2.6.26).[src] In Linux systems where POSIX capabilities are used, the ability to ptrace is further limited by the CAP_SYS_PTRACE capability or by the YAMA Linux Security Module.[src] In FreeBSD, it is limited by FreeBSD jails and Mandatory Access Control policies.[src] ==Limitations== Communications between the controller and target take place using repeated calls of ptrace, passing a small fixed-size block of memory between the two (necessitating two context switches per call); this is acutely inefficient when accessing large amounts of the target's memory, as this can only be done in word sized blocks (with a ptrace call for each word).[src] For this reason the 8th edition of Unix introduced procfs, which allows permitted processes direct access to the memory of another process - 4.4BSD followed, and the use of /proc for debugger support was inherited by Solaris, BSD, and AIX, and mostly copied by Linux.[src] Some, such as Solaris, have removed ptrace as a system call altogether, retaining it as a library call that reinterprets calls to ptrace in terms of the platform's procfs.[src] Such systems use ioctls on the file descriptor of the opened /proc file to issue commands to the controlled process.[src] FreeBSD, on the other hand, extended ptrace to remove mentioned problems, and declared procfs obsolete due to its inherent design problems.[src] ptrace only provides the most basic interface necessary to support debuggers and similar tools.[src] Programs using it must have intimate knowledge of the specifics of the OS and architecture, including stack layout, application binary interface, system call mechanism, name mangling, the format of any debug data, and are responsible for understanding and disassembling machine code themselves.[src] Further, programs that inject executable code into the target process or (like gdb) allow the user to enter commands that are executed in the context of the target must generate and load that code themselves, generally without the help of the program loader.[src] ==Support== ==References== ==External links== Article from Linux Gazette about ptrace Article about ptrace in linux journal[src]

25 sentences · 25 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Ptrace." encyclopegia.org, 2026, https://encyclopegia.org/wiki/ptrace. Accessed 30 November 2026.

Chicago

"Ptrace." encyclopegia.org. Accessed November 30, 2026. https://encyclopegia.org/wiki/ptrace.

APA

encyclopegia.org. (2026). Ptrace. Retrieved November 30, 2026, from https://encyclopegia.org/wiki/ptrace

Accessed November 30, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1353580454 · 0.5 · snapshot enwiki-001353580454

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.