# PID

Canonical page: https://vitalsmac.com/glossary/pid

Activity Monitor glossary, When something goes wrong. What is PID in Activity Monitor?

Also: process ID

**Short answer:** A PID, or process ID, is a number macOS assigns to each running process to identify it. No two running processes share a PID, but a number can be reused after its process ends.

Activity Monitor shows the PID in its own column. Terminal commands such as `kill`, `sample`, and `lsof` use the PID to know which process you mean, since several processes can have the same name.

On macOS, PID 0 is kernel_task and PID 1 is launchd, the first process that starts the rest of the system. Apps you open get higher numbers, and a new PID each time they launch.

## How to find the PID of an app

In Activity Monitor, find the app in the list and read the PID column. If the column is hidden, choose View > Columns > PID.

In Terminal, `pgrep -l Safari` lists matching processes with their PIDs. `ps -p <PID> -o pid,ppid,comm` shows a process's name and its parent's PID.

## What a parent PID tells you

Every process except the very first has a parent, the process that started it. Choosing View > All Processes, Hierarchically in Activity Monitor shows these parent and child relationships as a tree.

## How to find a PID in Terminal

Process names in Terminal can differ from app names. Many apps run helper processes with names like "App Helper (Renderer)", each with its own PID.

1. Open Terminal from Applications > Utilities.
2. Run `pgrep -lx Finder` to get the PID of a process whose name is exactly Finder. Leave out `x` to match part of a name.
3. If an app has several processes, run `pgrep -lf "Google Chrome"` to match against the full command line.
4. To see your own shell's PID, run `echo $$`.

## How to find which app a PID belongs to

Error messages and log files often mention a PID without a name. To look it up, run `ps -p <PID> -o pid,ppid,user,command`. It shows the full path of the program, which user runs it, and the PID of its parent.

In Activity Monitor, click the PID column header to sort by it, then scroll to the number. Double-click the process to open its info window, which also shows its parent process.

If `ps` prints nothing, the process has already exited.

## What you can do with a PID

Check the name first with `ps -p <PID>`. PIDs are reused, so a number you copied earlier may now belong to a different process.

- `kill <PID>` asks the process to quit. `kill -9 <PID>` ends it immediately.
- `sample <PID> 5` records what the process is doing for 5 seconds.
- `lsof -p <PID>` lists the files and network connections it has open.
- `lsof -a -p <PID> -d cwd` shows the folder it is running in.
- `top -pid <PID>` shows its live CPU and memory use. Press q to exit.

## When to use a PID instead of a name

Commands that work by name, such as `killall Safari` or `pkill Safari`, act on every process that matches. By default `killall` sends the quit signal to all matching processes you own, and `pkill` matches any process whose name contains the text you type.

That is fine for a single app, but risky when many processes share a name. A browser can run dozens of helper processes, and several copies of `node` or `python` may belong to different projects. A PID targets exactly one process, so use it when you want to stop one and leave the rest running.

If you do use a name, preview the matches first. `pgrep -l <name>` lists what `pkill` would act on, and `killall -d <name>` prints what `killall` would do without sending anything.

## Questions people ask

### What does PID mean in Activity Monitor?

PID stands for process ID. It is a unique number for each running process, used to tell processes apart and to target them with Terminal commands.

### Does an app keep the same PID?

Only while it runs. When you quit and reopen an app, it gets a new PID.

### What is PID 1 on a Mac?

PID 1 is launchd, the process that starts and manages other processes on macOS. It should never be quit.

### How do I kill a process by PID on a Mac?

Run `kill <PID>` in Terminal. If it does not exit, `kill -9 <PID>` ends it immediately, which can lose unsaved data.

### Can two processes have the same PID?

Not at the same time. A PID can be given to a new process after the old one exits.

### What is PID 0 in Activity Monitor?

PID 0 is kernel_task, which represents the macOS kernel. It cannot be quit.

## Related

- [launchd](https://vitalsmac.com/glossary/launchd)
- [kernel_task](https://vitalsmac.com/glossary/kernel-task)
- [Force Quit](https://vitalsmac.com/glossary/force-quit)
- [Zombie process](https://vitalsmac.com/glossary/zombie-process)

Looking for something better than Activity Monitor? See [the best Activity Monitor alternatives for Mac](https://vitalsmac.com/best-activity-monitor-alternatives), or [every term in the glossary](https://vitalsmac.com/glossary).
