memfd.org
← All notes

Linux / observability

A quiet look inside /proc

A few useful views into a running process, using the tools already on the machine.

On Linux, /proc exposes information about processes and parts of the kernel through a filesystem interface. Many of its files are generated when read; they are views of a running system rather than ordinary documents on disk.

Begin with your own process

# Basic information about the current shell.
cat /proc/$$/status

# Command-line arguments are separated by NUL bytes.
tr '\0' ' ' < /proc/$$/cmdline
printf '\n'

# Open descriptors, where permissions allow inspection.
ls -l /proc/$$/fd

A snapshot is not a transaction

A process may exit between listing its directory and opening a file. Values can change between reads. Inspection tools need to handle disappearing paths and partial observations as normal conditions.

Visibility has boundaries

Permissions, mount options, namespaces, and kernel settings affect what a process can inspect. A missing or unreadable view does not automatically mean the process is absent. Start with the narrowest question and use the least information needed to answer it.

← Back to the notebook