Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Signals

Direct answer

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.

When to use this

Use it to stop or reload processes, or when a process will not die.

First 30 seconds

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.

Operational verification

signal sent (kill, keyboard, kernel) → delivered → process handler runs or default action (terminate, stop, ignore)

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to stop or reload processes, or when a process will not die.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points

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.

Key checks
  • kill -l — list signal names and numbers
  • ps -o pid,stat,cmd -p <pid> — process state
  • bash -x script.sh — trace each expanded command
  • bash -n script.sh — syntax check only
  • shellcheck script.sh — common bugs and quoting problems
  • echo $? — 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:

SignalNo.DefaultTypical use
SIGHUP1TerminateTerminal closed; many daemons reload their configuration
SIGINT2TerminateCtrl-C
SIGQUIT3Core dumpCtrl-\
SIGKILL9TerminateForced kill; can't be handled
SIGUSR1 / SIGUSR210 / 12TerminateApplication-defined (e.g. reopen logs)
SIGSEGV11Core dumpInvalid memory access
SIGPIPE13TerminateWriting to a pipe with no reader
SIGTERM15TerminatePolite termination request (the kill default)
SIGCHLD17IgnoreA child changed state
SIGCONT18ContinueResume a stopped process
SIGSTOP19StopForced pause; can't be handled
SIGTSTP20StopCtrl-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

CommandEffect
kill <pid>SIGTERM
kill -HUP <pid>SIGHUP (e.g. reload)
kill -9 <pid>SIGKILL: last resort; no cleanup
pkill -f pattern / killall nameBy name or command line
systemctl kill -s USR1 <unit>All processes of a service
kill -lList 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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:

SignalNumberDefaultTypical use
SIGHUP1TerminateReload config (many daemons)
SIGINT2TerminateCtrl+C
SIGQUIT3Core dumpCtrl+\\
SIGKILL9Kill (cannot be caught)Last resort
SIGTERM15TerminatePolite stop (kill, systemd stop)
SIGSTOP / SIGCONT19 / 18Stop / continueCtrl+Z, fg
SIGUSR1/210/12TerminateApp-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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
bash signalsshell trapSIGTERM bashlinux signal shell
Embedded reference data

Quick lookup tables

Signals operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Signals.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateShell 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 verificationPin 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 chainsignal 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 stateTrace requested/configured state through effective state to the observed workload result.
Failure boundarySignal 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 evidenceCorrelated 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 stateUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 boundarySignals
Topic pathShell & Bash → Signals
Runtime stateShell 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 chainsignal 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 boundarySignal 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 ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?