---
name: "pfind_any_locked"
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/pfind"
---

# pfind\_any\_locked(9)

locate a process by number

Part of [pfind(9)](/pfind/9.md).

## NAME

**pfind**, **pfind\_any**, **pfind\_any\_locked** – locate a process by number

## SYNOPSIS

**#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*);

## DESCRIPTION

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.

## SEE ALSO

[pget(9)](/pget/9.md), [pgfind(9)](/pgfind/9.md)

## AUTHORS

This manual page was written by Evan Sarmiento ⟨*kaworu@sektor7.ath.cx*⟩.
