How do you manage background processes and signals?
Bash can start, inspect and signal processes. Append & to run a job in the background and $! holds its PID. wait blocks until it finishes.
sleep 30 &
pid=$!
kill -TERM "$pid" # ask to stop, catchable
sleep 1
kill -KILL "$pid" # forced, cannot be caught
wait "$pid" 2>/dev/null || true
jobs -l
Useful signals are SIGTERM for graceful shutdown, SIGINT from Ctrl-C, SIGHUP for reload or terminal close, SIGKILL for force and SIGSTOP/SIGCONT to pause and resume. kill -l lists signal names and numbers.
Trap signals for cleanup with trap 'echo bye; exit' TERM INT. pkill and pgrep match by name, while kill 0 signals the whole process group. Prefer tracking PIDs over killall, because name matching can hit unrelated processes, and never kill a PID you did not start.