pfind_any(9)

pfind_any9

Locate a process by number

Part of pfind(9).

Usage

#include <sys/param.h>

#include <sys/proc.h>

struct proc *

pfind(pid_t pid);

struct proc *

pfind_any(pid_t pid);

struct proc *

pfind_any_locked(pid_t pid);

Overview

The pfind() function walks the list of processes in the system, looking for the one with a process ID of pid. If the process exists, and is not in the zombie state, a pointer to the process structure will be returned.

pfind_any() takes a pid as its argument. pfind_any() searches the allproc list and returns the first process with a matching PID, whose state may be PRS_ZOMBIE.

pfind_any_locked() is similar to pfind_any(), but it does not lock the process hash bucket for the given pid. Instead, it asserts the corresponding process hash bucket is already locked.

All three functions pfind(), pfind_any(), and pfind_any_locked() lock the proc structure before returning.

Return values

pfind(), pfind_any(), and pfind_any_locked() return pointer to a proc structure on success or NULL on failure.

Releases

Unchanged in 2 releases since FreeBSD 15.1-RELEASE.

  1. 15.1–16.0

Authors

This manual page was written by Evan Sarmiento ⟨[email protected]⟩.

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