Full Byte Developer.

What is a process?

A process is a running program with its own PID, memory space, and credentials the kernel tracks.

Published here , updated · 4 sources

A process is a running program the kernel tracks with its own process ID, memory space, and credentials [1][2]. One executable file on disk can become many processes if you start it many times; each instance gets its own PID and address space. Pair with what is a container when namespaces wrap those processes.

Prove fork isolation with a tiny C program

Linux fork() creates a child that is a near duplicate of the parent [1]. Parent and child run in separate memory spaces; at the fork instant contents match, but later writes in one do not change the other [1]. The child receives its own PID; the parent sees the child's PID as the return value, and the child sees 0 [1].

fork_demo.c
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int g = 0;
int main(void) {
    pid_t p = fork();
    if (p == 0) {
        g = 42;
        printf("child pid=%d ppid=%d g=%d\n", (int)getpid(), (int)getppid(), g);
        return 0;
    }
    usleep(100000);
    printf("parent pid=%d child=%d g=%d\n", (int)getpid(), (int)p, g);
    return 0;
}
bash
gcc -Wall -o fork_demo fork_demo.c
./fork_demo

Captured output (gcc 13.3.0, Linux x86_64):

text
child pid=43013 ppid=43011 g=42
parent pid=43011 child=43013 g=0

The child sets global g to 42; the parent still reads 0. PIDs differ; PPID links child to parent [2].

Draw the fork moment

before: PID A one address space fork() parent PID A return = child PID child PID B return = 0 After the child writes g=42, parent still sees g=0: copy-on-write split the page [1]. Credentials and open files start as copies; later changes stay local unless shared on purpose [2].

Linux implements fork with copy-on-write: page tables split cheaply; physical copies happen when a page is written [1].

Create with fork, then often exec

Shells fork a child, then replace the child's program image with execve on the command you typed. The PID often stays the same across exec; the memory image becomes the new binary [1]. Pipelines fork multiple children. Job control uses process groups so signals can hit a foreground group together [2].

The executable on disk is a file. A process is that image loaded into memory with stacks, heap, open file descriptors, and environment. You can list processes with ps while the binary file sits unchanged in /usr/bin.

Read the IDs the kernel cares about

From credentials(7) [2]:

  1. PID: unique id for this process.
  2. PPID: parent that created it via fork.
  3. Process group and session: job-control groupings for shells and terminals.
  4. Real and effective user and group: who owns the process and which permissions apply.

A child inherits copies of the parent's user and group IDs at fork [2]. Setuid binaries change effective UID when the kernel allows it; file permission checks use those credentials.

Inspect the live tree with ps

bash
ps -eo pid,ppid,stat,comm | head -6

Captured on this host (procps-style columns):

text
    PID    PPID STAT COMMAND
      1       0 Ss   tini
      7       1 Sl   pod-daemon
    343       7 Ssl  node
    731       1 S    desktop-init.sh
    953       7 Ssl  cursor-agent-st

Column PPID is the parent PID from credentials(7) [2]. State letters describe running, sleeping, zombie, and stopped jobs. One supervisor spawning shells is normal in dev containers; production trees differ but the fields are the same [2].

On Linux, /proc/<pid>/ exposes status files the kernel maintains. ps reads those nodes; it is not a single syscall named "list every process" [2]. When debugging, cat /proc/<pid>/cmdline shows the argv the kernel recorded.

Signals, exit codes, and zombies

When a child exits first, the parent should wait (explicitly or via the shell) to reap its zombie entry [1]. A zombie is a finished process row waiting for the parent to read its status. Orphaned children get reparented to init or a subreaper.

Signals such as SIGTERM ask a process to exit; SIGKILL stops it without cleanup. Process groups let you signal a pipeline as a unit [2]. Shells surface exit codes from the last foreground command; background jobs need explicit wait or job control.

Keep isolation in mind

Separate address spaces are why multi-process designs survive a crash in one sibling more often than shared-memory threads do. Tradeoff: inter-process communication (pipes, sockets, shared memory) costs more than a lock inside one process [1].

Containers and namespaces add another layer: processes can share a kernel but see different PID namespaces, mount trees, or network stacks (what is a container). The fork and credentials vocabulary still applies inside each namespace. Long-running network listeners are still processes; the service role is covered in what is a server.

Scheduling in one paragraph

The kernel scheduler picks which runnable process gets CPU time. Nice values and cgroups bias priority; this page does not spell cgroup v2 rules. For teaching, remember: many processes, one kernel, time sliced. Heavy CPU in one process can delay siblings unless isolated by limits.

Wait status and exit codes

When a child exits before the parent calls wait, the child becomes a zombie until the parent reaps it [1]. The row stays in the process table with status bits but no memory image. Orphans adopt a new parent, often PID 1. Long lists of zombies point at a parent that never waits.

Shells surface exit codes from the last foreground command. Pipelines and background jobs need explicit wait or job control built into the shell. A non-zero exit is a process-level signal to the caller; it is not the same thing as a kernel oops.

File descriptors across fork and exec

Children inherit copies of open file descriptors at fork unless you marked them close-on-exec [1]. That inheritance is how shells wire pipes between pipeline stages. It is also how a forgotten open log file stays open in a daemon after exec. When debugging "why is this file still locked," count processes and inspect /proc/<pid>/fd.

Mistakes that blur the picture

Saying "the app crashed" when one worker died but supervisors respawned. Check how many PIDs listen on the port.

Expecting fork to copy every byte eagerly. Copy-on-write defers physical duplication until writes [1].

Treating threads as mini-processes with a separate heap by default. Threads in one process usually share the address space.

Using kill -9 as the first debug step. You lose core dumps and graceful shutdown.

Forgetting that exec replaces the program but keeps the same PID and some open file descriptors unless marked close-on-exec [1].

Equating PID with port. Many processes share no network port; many containers can NAT the same host port to different PIDs.

Calling a container "not a process." Namespaces wrap processes; they do not replace the PID model (what is a container).

What you have now

A sourced Linux process picture: PID, fork isolation measured on this host, and credentials from the man pages [1][2]. When someone says "the app," ask how many PIDs are involved. Long-running network listeners are still processes playing a server role (what is a server).

Browse the Dev explainers topic.

Send this to the friend who says the app when they mean twelve cooperating processes.

Two dark matte cubes on a grid floor separated by a vertical translucent glass pane; left cube shows an orange diamond, right cube shows a teal button with a hanging metal ID tag, cyan arrows flowing between them.
Each process is its own tracked unit with an identity tag; the kernel keeps address spaces apart even when they talk.

Keep this guide

By Full Byte Developer

Filed under Dev explainers

Questions about this guide

How does a new process appear on Linux?

fork(2) duplicates the calling process into a child with its own PID and separate memory space. Programs often then exec a new image.

What is a PID?

credentials(7): each process gets a unique nonnegative process ID at creation. Tools like kill and wait use that ID.

Is a thread the same as a process?

No. Threads usually share one process address space. Separate processes get separate page tables after fork.

What is copy-on-write after fork?

Linux marks pages read-only at fork and copies them on write. Parents and children split physically only when one side modifies a page.

Where should I go next?

Read what is a container for namespaces around processes, then what is a server for the long-running service role.

Sources

Next in this stack