pget(9)

pget9

Locate a process by number

Usage

#include <sys/param.h>

#include <sys/proc.h>

int

pget(pid_t pid, int flags, struct proc **pp);

Overview

This function takes a pid as its argument, which can be either a process or thread id, and fills a pointer to the proc structure in *pp. In the latter case, a process owning the specified thread is looked for. The operation is performed by invoking the pfind(9) function. The found process is returned locked. For the PGET_HOLD case, it is returned unlocked (but held). The pget() function can perform additional manipulations, depending on a flags argument.

The flags argument is the logical OR of some subset of:

PGET_HOLD

If set, the found process will be held and unlocked.

PGET_CANSEE

If set, the found process will be checked for its visibility. See p_cansee(9).

PGET_CANDEBUG

If set, the found process will be checked for its debuggability. See p_candebug(9).

PGET_ISCURRENT

If set, the found process will be checked that it matches the current process context.

PGET_NOTWEXIT

If set, the found process will be checked that it does not have the process flag P_WEXIT set.

PGET_NOTINEXEC

If set, the found process will be checked that it does not have the process flag P_INEXEC set.

PGET_NOTID

If set, pid is not assumed as a thread id for values larger than PID_MAX.

PGET_WANTREAD

If set, the found process will be checked that the caller may get a read access to its structure. A shorthand for (PGET_HOLD | PGET_CANDEBUG | PGET_NOTWEXIT).

Return values

If the process is found in the specified way, then zero is returned, otherwise an appropriate error code is returned.

Releases

30 releases since FreeBSD 9.3-RELEASE; the text changed 16 times.

  1. 9.3
  2. 10.1
  3. 10.2
  4. 10.3
  5. 10.4
  6. 11.0
  7. 11.1
  8. 11.2
  9. 11.3
  10. 11.4
  11. 12.0
  12. 12.1
  13. 12.2
  14. 12.3
  15. 12.4
  16. 13.0–13.2
  17. 13.3–16.0

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.