1. How a command becomes a process
One-liner. The shell forks itself, execs the program, and waits for a status code.
Memorize
fork()duplicates the process (copy-on-write);execve()replaces its memory image with a new program.- The shell is a normal process; job control is just process groups plus terminal signals.
- PID 1 (
systemd) reaps orphans and runs as the ancestor of everything; it cannot be killed normally. - Every process has a parent, a process group, a session, and a controlling terminal.
$?is the exit status;0= success,1–125program-defined,126not executable,127not found,128+nkilled by signal n.- A zombie is exited but unreaped; an orphan is reparented to PID 1 (or a subreaper).
&,jobs,fg,bg,disown,nohupare job-control conveniences, not new mechanisms.
Trap. Killing a process with kill <pid> when it ignores SIGTERM — kill sends TERM by default, which can be caught. Do this. kill -TERM, wait, then kill -KILL (SIGKILL cannot be caught or cleaned up).
Check
What does kill -9 <pid> guarantee that kill <pid> does not?
Why
SIGKILL cannot be caught or ignored, so it cannot be delayed — but it also skips cleanup, risking corruption.