Processes, PIDs and state
Quick answer
A process is a running instance of a program, with an identity and execution state. Inspect a child you started instead of guessing from a command name.
Prepare the practice environment
Use an ordinary user in an authorized disposable Linux VM. From the extracted package root run python3 lab-fixtures/processes/setup.py, enter its printed path and check pwd. Run each executable example in a fresh Bash process with LC_ALL=C and set -o pipefail. Do not use sudo. For interactive examples use a fresh interactive Bash and enter one command at a time. Signal only the just-started bounded child, never an arbitrary PID. Wait for completion before discarding the private workspace. Skip absent tools.
How it works
The kernel assigns a PID within a PID namespace. PPID identifies the parent at the moment of inspection; PIDs can be reused. ps is a snapshot, not a continuous monitor. Common leading STAT letters are R (running or runnable), S (interruptible sleep), D (uninterruptible sleep, often I/O), T (stopped) and Z (exited but not yet reaped). Extra STAT characters are modifiers. A zombie does not execute or respond to termination signals; its parent must collect the exit status. A long-lived zombie population suggests a parent-side issue. A blocked D-state task may not immediately respond to a signal. pstree depicts parent relationships; pgrep selects matching PIDs, and pidof finds processes by program name. A name match is not proof of ownership or identity.
In the examples, $! records the PID of the child just started and $$ identifies the running Bash shell in this context. Comparing the child PPID to the shell PID tests a parent relationship at that instant. A name search may find other children, so compare its results to the captured PID instead of assuming the first match is the intended task. The child may exit before a later observation; a missing row is not automatically a system failure. Use wait to collect the status of the known child.
Try the examples
The shell PID is supplied by $$. This selects only the current Bash process.
Expected stdout:
bashsleep 1 &child=$!ps -p "$child" -o ppid= | awk -v parent="$$" '$1 == parent {print "parent matches"}'wait "$child"The background sleep has a finite lifetime; wait collects its status. The PID is dynamic.
Expected stdout:
parent matchessleep 1 &child=$!pgrep -P "$$" -x sleep | awk -v child="$child" '$1 == child {print "child found"}'wait "$child"The parent restriction and exact name narrow the query; the captured PID verifies the intended child.
Expected stdout:
child foundCommon mistakes
Do not signal a process merely because its name matches. PID reuse, namespaces, other users and services make broad selection unsafe.
Practice
Start a one-second sleep, inspect its PID, PPID and STAT with ps, then wait. Explain why Z cannot be fixed by killing the zombie.
Related references
Study: ps, pstree, pgrep, pidof. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Processes, PIDs and state — Knowledge Check
Apply process lifecycle and job-control concepts to a bounded child-process lab.
What is PPID?
What does Z mean?
What does ps show?
Why capture $!?