---
name: "kinfo_getproc"
section: "3"
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/kinfo_getproc"
---

# kinfo\_getproc(3)

function for getting process information from kernel

## NAME

**kinfo\_getproc** – function for getting process information from kernel

## LIBRARY

System Utilities Library (libutil, -lutil)

## SYNOPSIS

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

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

**#include \<libutil.h\>**

*struct* *kinfo\_proc* *\**\

**kinfo\_getproc**(*pid\_t pid*);

## DESCRIPTION

This function is used for obtaining process information from the kernel.

The *pid* field contains the process identifier. This should be a process that you have privilege to access. This function is a wrapper around [sysctl(3)](/sysctl/3.md) with the KERN\_PROC\_PID mib. While the kernel returns a packed structure, this function expands the data into a fixed record format.

## RETURN VALUES

On success the **kinfo\_getproc**() function returns a pointer to a *struct* *kinfo\_proc* structure as defined by ⟨sys/user.h⟩. The pointer was obtained by an internal call to [malloc(3)](/malloc/3.md) and must be freed by the caller with a call to [free(3)](/free/3.md). On failure the **kinfo\_getproc**() function returns NULL.

## SEE ALSO

[free(3)](/free/3.md), [malloc(3)](/malloc/3.md), [sysctl(3)](/sysctl/3.md)

## HISTORY

The **kinfo\_getproc**() function first appeared in FreeBSD 7.0.
