---
name: "pget"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pget"
---

# pget(9)

locate a process by number

## NAME

**pget** – locate a process by number

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/proc.h\>**

*int*\

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

## DESCRIPTION

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)](/pfind/9.md) 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)](/p_cansee/9.md).

- PGET\_CANDEBUG

  If set, the found process will be checked for its debuggability. See [p\_candebug(9)](/p_candebug/9.md).

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

## SEE ALSO

[p\_candebug(9)](/p_candebug/9.md), [p\_cansee(9)](/p_cansee/9.md), [pfind(9)](/pfind/9.md)
