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.