Use it to stop or reload processes, or when a process will not die.
Signals
Signals are notifications the kernel sends to processes: SIGINT (2, Ctrl+C), SIGTERM (15, polite stop), SIGKILL (9, cannot be caught), SIGHUP (1, hangup/reload), SIGSTOP/SIGTSTP (pause) and SIGCONT. kill sends them.
1. ps -o pid,stat,cmd -p <pid> — state? D = waiting on I/O.
2. kill <pid> (SIGTERM) and wait.
3. Still running → kill -9 <pid>.
4. D state → fix the I/O (NFS, disk) instead.
5. Services → systemctl stop/reload rather than kill.
signal sent (kill, keyboard, kernel) → delivered → process handler runs or default action (terminate, stop, ignore)
For Shell & Bash → Signals, continue with the first unproven Topic check: Identify exact PID/process group/session and verify it still refers to the intended process before signaling. If that boundary is healthy, advance to the adjacent check: Use TERM/INT/HUP semantics appropriate to the application and reserve KILL for unresponsive processes after evidence capture when possible. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
signal source/terminal/controller → target PID or process group → kernel permission + delivery → process disposition/trap/default action → exit/reload/stop/continue → parent wait status → service/workload state
Healthy evidence: the correct process/group receives the intended signal, trap/default behavior is observed and resulting process/service/workload state matches the requested action.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Identify exact PID/process group/session and verify it still refers to the intended process before signaling.
- Use TERM/INT/HUP semantics appropriate to the application and reserve KILL for unresponsive processes after evidence capture when possible.
- Inspect traps and cleanup paths for scripts; test expected signals explicitly.
- After signaling, verify process exit/reload/state plus application readiness/data integrity rather than signal-send status alone.
Verification chain. signal source/terminal/controller → target PID or process group → kernel permission + delivery → process disposition/trap/default action → exit/reload/stop/continue → parent wait status → service/workload state
Step 3 Commands Verify boundary
kill -l
kill -TERM <pid>
trap 'cleanup' INT TERM
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: a recycled PID or wrong process group is signaled, SIGKILL bypasses cleanup, or kill success is mistaken for graceful application completion.
Step 5 Common mistakes Narrow the fault
- Using SIGKILL first, skipping cleanup.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Send SIGTERM first and give the process time to clean up; use SIGKILL only if it hangs. A process stuck in D state (uninterruptible I/O) ignores even SIGKILL until the I/O finishes. Scripts can catch signals with trap.
kill -l— list signal names and numbersps -o pid,stat,cmd -p <pid>— process statebash -x script.sh— trace each expanded commandbash -n script.sh— syntax check onlyshellcheck script.sh— common bugs and quoting problemsecho $?— exit code of the last command
ReferenceWhat it is1 section · depth on demand
Core model
Signals target processes or process groups, not abstract commands. Distinguish terminal-generated signals, kill(2)-delivered signals and shell traps; understand that SIGKILL/SIGSTOP cannot be trapped, traps run at shell-defined safe points, and children may inherit/reset dispositions across fork/exec.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
Signal verification requires observing the target's resulting process/application state; successful delivery request alone does not show graceful termination, reload or cleanup.
In depth
Signals: sending, handling and default actions
Signals are asynchronous notifications to a process: requests to stop, reload, pause or continue. The signal(7) manual page lists the standard signals with their numbers on x86 and their default actions:
| Signal | No. | Default | Typical use |
|---|---|---|---|
| SIGHUP | 1 | Terminate | Terminal closed; many daemons reload their configuration |
| SIGINT | 2 | Terminate | Ctrl-C |
| SIGQUIT | 3 | Core dump | Ctrl-\ |
| SIGKILL | 9 | Terminate | Forced kill; can't be handled |
| SIGUSR1 / SIGUSR2 | 10 / 12 | Terminate | Application-defined (e.g. reopen logs) |
| SIGSEGV | 11 | Core dump | Invalid memory access |
| SIGPIPE | 13 | Terminate | Writing to a pipe with no reader |
| SIGTERM | 15 | Terminate | Polite termination request (the kill default) |
| SIGCHLD | 17 | Ignore | A child changed state |
| SIGCONT | 18 | Continue | Resume a stopped process |
| SIGSTOP | 19 | Stop | Forced pause; can't be handled |
| SIGTSTP | 20 | Stop | Ctrl-Z |
The manual states that SIGKILL and SIGSTOP can't be caught, blocked or ignored. A child created by fork inherits its parent's signal mask. execve resets handled signals to their defaults, but signals that were ignored stay ignored.
Sending signals
| Command | Effect |
|---|---|
kill <pid> | SIGTERM |
kill -HUP <pid> | SIGHUP (e.g. reload) |
kill -9 <pid> | SIGKILL: last resort; no cleanup |
pkill -f pattern / killall name | By name or command line |
systemctl kill -s USR1 <unit> | All processes of a service |
kill -l | List the signal names |
Handling signals in scripts
host$ cat worker.sh
#!/usr/bin/env bash
cleanup() { echo "stopping, removing lock" >&2; rm -f /run/lock/worker.lock; exit 0; }
trap cleanup TERM INT
trap 'echo "reloading config" >&2' HUP
touch /run/lock/worker.lock
while true; do sleep 5; done
host$ ./worker.sh & pid=$!
host$ kill -HUP $pid
reloading config
host$ kill $pid
stopping, removing lock
host$ grep -E "^Sig(Blk|Ign|Cgt)" /proc/$(pgrep -o nginx)/status
SigBlk: 0000000000000000
SigIgn: 0000000000001000
SigCgt: 0000000188016a07
Why SIGTERM before SIGKILL
SIGTERM lets a program close files, release locks and finish transactions. SIGKILL ends it instantly, which can leave stale locks or half-written data. systemd follows the same order on stop: SIGTERM, then SIGKILL after TimeoutStopSec=.
Reading /proc/<pid>/status
SigIgn and SigCgt are bitmasks of ignored and caught signals. Bit n−1 stands for signal n. In the example, bit 12 (0x1000) set in SigIgn means nginx ignores SIGPIPE (13).
Documented example, not captured output.
How it works at runtime
Signals is part of Shell & Bash → Signals. Shell Signals covers how Bash and child processes receive asynchronous POSIX signals, how interactive job control maps terminal actions to process groups, and how traps/termination statuses affect shell-script cleanup.
Topic-specific state model. Shell Signals covers how Bash and child processes receive asynchronous POSIX signals, how interactive job control maps terminal actions to process groups, and how traps/termination statuses affect shell-script cleanup.
Interpretation rule. - SIGTERM sent ≠ process exited or cleanup completed.
- kill command success ≠ target handled the signal as desired; it can only show signal delivery request accepted for the target identity at that instant.
- Ctrl-C ≠ necessarily one PID; terminal job control commonly signals the foreground process group.
- trap installed ≠ it runs on SIGKILL, power loss or every shell-exit path.
Quick reference
Signals are asynchronous notifications to processes:
| Signal | Number | Default | Typical use |
|---|---|---|---|
| SIGHUP | 1 | Terminate | Reload config (many daemons) |
| SIGINT | 2 | Terminate | Ctrl+C |
| SIGQUIT | 3 | Core dump | Ctrl+\\ |
| SIGKILL | 9 | Kill (cannot be caught) | Last resort |
| SIGTERM | 15 | Terminate | Polite stop (kill, systemd stop) |
| SIGSTOP / SIGCONT | 19 / 18 | Stop / continue | Ctrl+Z, fg |
| SIGUSR1/2 | 10/12 | Terminate | App-defined (log reopen) |
kill -TERM 1234; kill -l
pkill -HUP -x nginx
trap 'cleanup; exit 130' INT TERM
Always try SIGTERM first; SIGKILL skips cleanup and can leave locks or corrupted state.
Limits and how it fails
Primary failure point. Signal verification requires observing the target's resulting process/application state; successful delivery request alone does not show graceful termination, reload or cleanup.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Processes owns process lifecycle/job states; systemd & Services owns service-level stop/reload policy; this Topic owns Bash/shell interaction with signals and traps.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Shell & Bash → Signals. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.gnu.org/software/bash/manual/bash.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Signals operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Signals.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Shell Signals covers how Bash and child processes receive asynchronous POSIX signals, how interactive job control maps terminal actions to process groups, and how traps/termination statuses affect shell-script cleanup. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host/distribution + shell/version/mode → identify cwd/mount namespace + input/path/stream → preserve quoting/expansion and final argv → map fd/pipeline/process boundaries → inspect object/variable/status/signal state → make one minimal reversible change → read back effective state → repeat original consumer/script/workload test. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | signal source/terminal/controller → target PID or process group → kernel permission + delivery → process disposition/trap/default action → exit/reload/stop/continue → parent wait status → service/workload state | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Signal verification requires observing the target's resulting process/application state; successful delivery request alone does not prove graceful termination, reload or cleanup. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux file/text/shell evidence can establish this proof path: signal source/terminal/controller → target PID or process group → kernel permission + delivery → process disposition/trap/default action → exit/reload/stop/continue → parent wait status → service/workload state | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured host, shell/session, cwd/namespace, input, process, filesystem, locale, time or workload scope. Signal verification requires observing the target's resulting process/application state; successful delivery request alone does not prove graceful termination, reload or cleanup. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven boundary: capture the exact shell-delivered argv/streams or resolved object, verify the effective target state, change only the demonstrated cause, then repeat the original consumer/script/workload and adjacent regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
Signals · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Signals |
|---|---|
| Topic path | Shell & Bash → Signals |
| Runtime state | Shell Signals covers how Bash and child processes receive asynchronous POSIX signals, how interactive job control maps terminal actions to process groups, and how traps/termination statuses affect shell-script cleanup. |
| Fast checks | - Identify exact PID/process group/session and verify it still refers to the intended process before signaling. - Use TERM/INT/HUP semantics appropriate to the application and reserve KILL for unresponsive processes after evidence capture when possible. - Inspect traps and cleanup paths for scripts; test expected signals explicitly. - After signaling, verify process exit/reload/state plus application readiness/data integrity rather than signal-send status alone. |
| Verification chain | signal source/terminal/controller → target PID or process group → kernel permission + delivery → process disposition/trap/default action → exit/reload/stop/continue → parent wait status → service/workload state Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | Signal verification requires observing the target's resulting process/application state; successful delivery request alone does not prove graceful termination, reload or cleanup. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |