A PID (Process ID) is the unique integer identifier assigned to each running process by the kernel. PIDs are allocated sequentially from 1 (init) up to a maximum set by /proc/sys/kernel/pid_max (traditionally 32768, often raised to 4 million on modern systems), wrapping around once they hit that ceiling. The kernel guarantees that no two running processes share a PID at any given moment.
You see PIDs everywhere: in ps, top, htop, /proc/<PID>/, kill <PID>, lsof -p <PID>, and strace -p <PID>. The shell variable `$$` expands to the shell's own PID, while `$!` gives the PID of the most recently backgrounded job.
```bash
echo $$ # current shell's PID
sleep 100 &
echo $! # the sleep's PID
kill $! # signal it
PIDs are reused after their process exits, which can cause subtle races: by the time you try to kill PID 12345, that PID may belong to a completely different process. The **pidfd** interface (and `pidfd_open` system call) was added to eliminate this race: a pidfd refers to a specific process and becomes invalid when it exits, rather than silently targeting a new one.
Related terms: Process
Discussed in:
- Chapter 10: Processes and Job Control · What a Process Is
Also defined in: Textbook of Linux
