---
name: "readproc"
section: "3"
platform: "linux"
package: "procps"
version: "2:3.3.17-5"
release: "Debian 11 (Bullseye)"
platforms: ["linux"]
url: "https://new.carta.tech/readproc"
---

# readproc(3)

read information from next /proc/## entry

## NAME

readproc, freeproc  - read information from next /proc/## entry

## SYNOPSIS

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

**proc\_t\* readproc(PROCTAB \****PT***, proc\_t \****return\_buf***);**\
 **void freeproc(proc\_t \****p***);**

## DESCRIPTION

**readproc** reads the information for the next process matching the criteria specified in *PT* and fills them into a *proc\_t* structure. If *return\_buf* is not NULL, it will use the struct pointed at by *return\_buf*. Otherwise it will allocate a new *proc\_t* structure and return a pointer to it. Note that (if so specified in *PT*) readproc always allocates memory if it fills in the *environ* or *cmdline* parts of *proc\_t*.

**freeproc** frees all memory allocated for the *proc\_t* struct *\*p*.

The *proc\_t* structure is defined in *\<proc/readproc.h\>*, please look there for a definition of all fields.

## RETURN VALUE

**readproc** returns a pointer to the next *proc\_t* or NULL if there are no more processes left.

## SEE ALSO

[**openproc**(3)](/openproc/3.md), [**readproctab**(3)](/readproctab/3.md), **/usr/include/proc/readproc.h**, **/proc/#pid/**,

## REPORTING BUGS

Please send bug reports to ⟨procps@freelists.org⟩
