Lesson 14 / 29
Jobs & Signals
Foreground vs background, and the signals behind kill.
Foreground vs background
A foreground job occupies your terminal until it finishes. A background job (started with &) frees the terminal so you can keep working.
&, jobs, fg, bg
Start a job in the background, list jobs, and bring one back to the foreground.
sleep 100 &
jobs
fg %1 # bring job 1 to foreground
# Ctrl+Z suspends the foreground job, then:
bg %1 # resume it in background
Output:
[1] 5231 [1]+ Running sleep 100 &
Signals at a glance
SIGINT (Ctrl+C) asks a process to stop, SIGTERM (default kill) requests graceful shutdown, SIGKILL (-9) terminates immediately and cannot be caught or ignored.
Quick check: Which signal cannot be caught or ignored by a process?
- SIGTERM
- SIGINT
- SIGKILL
Answer
SIGKILL — SIGKILL (signal 9) is handled by the kernel directly and always terminates the process.