How do Linux signals work?

Answer

Signals are software interrupts sent to processes to notify them of events. Common signals: SIGHUP (1) — terminal hangup, often used to reload config; SIGINT (2) — Ctrl+C, interrupt; SIGQUIT (3) — Ctrl+\, quit with core dump; SIGKILL (9) — forceful kill, cannot be caught or ignored; SIGTERM (15) — graceful termination, can be caught; SIGUSR1/2 — user-defined; SIGCHLD — child process changed state. Send with kill -SIGNAL PID. In bash, handle signals with trap: trap 'echo caught; cleanup' SIGTERM. SIGKILL and SIGSTOP can never be caught or blocked — they are handled by the kernel directly.