---
title: "Process"
url: https://www.daytona.com/compute-glossary/kernel/process
---

# Process

Part of the [Compute Glossary](https://www.daytona.com/compute-glossary.md), section [Kernel](https://www.daytona.com/compute-glossary/kernel.md).

A process is a program that the [kernel](https://www.daytona.com/compute-glossary/kernel/kernel.md) has loaded into [memory](https://www.daytona.com/compute-glossary/hardware/memory.md) and is running. A program is a file on disk, while a process is one live copy of it, and one program can run as many processes at once. The copies can share the code of the program in physical memory, so each extra copy costs mainly its own data. On Linux, starting a program also loads the shared libraries it needs, through a small loader that runs before the program itself.

The kernel gives each process a numeric ID and a set of resources it owns. The process ends when the program exits or is killed, and the kernel then takes its resources back. The kernel frees them even when the program crashed without cleaning up, so a dead program cannot leak memory for good. Until its parent reads its exit status, an ended process lingers as a small entry called a zombie.

The process is the oldest isolation unit in an operating system, and the unit that the kernel isolates and accounts for, while its threads are what the kernel schedules. Higher layers build on it, so a [container](https://www.daytona.com/compute-glossary/virtualization/container.md) is a group of processes with extra limits around them. Tools that report processor and memory use read figures the kernel keeps for each process. Signals, such as a request to stop, are also addressed to a process by its ID.

## Process contents

Process contents are the state the kernel keeps for each process. Each process has its own virtual address space, so one process cannot read or write the memory of another unless both agree to share it. The address space holds the code and data of the program, along with the libraries and files mapped into it. Most of that space is empty, and the kernel backs only the parts in use with real memory.

A process also holds a table of open file descriptors, covering files and network sockets, along with a current directory. The kernel checks its user and group identity on every request it makes. Child processes inherit open descriptors, which is how a shell connects the output of one program to the input of the next. A process also carries environment variables, which programs read for settings.

A process runs as one or more threads. Threads in one process share its memory and files, but each has its own registers and stack, and the kernel schedules each thread onto a [CPU core](https://www.daytona.com/compute-glossary/hardware/cpu-core.md) separately. Threads are cheaper to create and switch between than processes, because no address space has to change. The shared memory is also the risk, since a bug in one thread can corrupt data that every other thread uses.

## Process creation

Process creation on Unix-like systems is the copying of an existing process. The fork [system call](https://www.daytona.com/compute-glossary/kernel/system-call.md) makes a child that is a near-exact copy of its parent, sharing memory pages copy-on-write so that the copy is cheap. The child gets a new process ID, and fork returns that ID to the parent and zero to the child. Each side checks the return value to learn which one it is.

The child then usually calls exec to replace itself with a different program. Every process therefore has a parent, and all of them descend from the first user-space process the kernel starts, called init. Splitting creation in two lets the child change its setup between the steps, such as redirecting its output or dropping privileges. Shells rely on this for every command they run.

The same idea appears higher up the stack. A sandbox fork copies a whole running machine rather than one process, using copy-on-write in the same way to make the copy fast. Where a process fork copies one address space, a sandbox fork also copies the disk and the state of every process in the machine. The memory-sharing trick carries over unchanged, but a machine also has devices and network state that a process copy never deals with.

## Process isolation

Process isolation is the separation the kernel keeps between processes by default. Separate address spaces keep processes from corrupting each other, and user IDs and file permissions limit what each one can touch. A process can still read any file its user may read, which on a shared system can be a lot. Root, the superuser, bypasses most of these checks entirely.

That is enough to keep programs from interfering by accident but not to contain a hostile one. Every process can see the others and the whole file system, and can use as much of the machine as it likes. It can also make any system call the kernel offers and try to exploit a bug in it. That is acceptable for programs a person chose to run, and not for code nobody has read.

Linux adds features that tighten this without leaving the process model. [Namespaces](https://www.daytona.com/compute-glossary/kernel/namespace.md) limit what a process can see, and [control groups](https://www.daytona.com/compute-glossary/kernel/cgroup.md) limit what it can use. [Seccomp](https://www.daytona.com/compute-glossary/kernel/seccomp.md) limits which system calls it can make. Each adds a layer without changing how programs are written, so ordinary software runs inside them unmodified.

## Related terms

- [Kernel](https://www.daytona.com/compute-glossary/kernel/kernel.md)
- [System call](https://www.daytona.com/compute-glossary/kernel/system-call.md)
- [Namespace](https://www.daytona.com/compute-glossary/kernel/namespace.md)
- [Control group](https://www.daytona.com/compute-glossary/kernel/cgroup.md)
