← Interview Prep

Linux Kernel — Signals

Asynchronous notifications: generation/pending/blocked/delivery, the signal catalogue and the uncatchable SIGKILL/SIGSTOP, standard (unqueued) vs real-time (queued) signals, sigaction/SA_RESTART/EINTR, async-signal-safety & the self-pipe/signalfd pattern, and signals vs threads.

Signals are the kernel's asynchronous notifications to a process — the software-interrupt layer of Unix. Simple to send, subtle to handle correctly. Original, interview-focused notes.

A signal is generated (by the kernel, another process, or the process itself), pending until it can be delivered, and delivered when the target next returns to user mode — running its default action or a registered handler. Two per-process bitmaps drive it: pending and blocked (the mask).

The catalogue

SignalDefaultNote
SIGTERM (15)TerminatePolite shutdown — catchable, the default kill.
SIGKILL (9)TerminateUncatchable, unblockable — the kernel acts, the process never sees it.
SIGSTOP / SIGCONTStop / continueSTOP is also uncatchable.
SIGSEGV / SIGBUSCore dumpBad memory access — a synchronous fault turned into a signal.
SIGCHLDIgnoredA child stopped/exited — the reaping hook.
SIGHUP (1)TerminateTerminal hangup; by convention "reload config".
SIGPIPETerminateWrote to a closed socket/pipe.
SIGUSR1/2TerminateApplication-defined.

SIGKILL and SIGSTOP can be neither caught, blocked, nor ignored — the one guarantee that lets you always stop a (schedulable) process.

Standard vs real-time signals

Handling — and its sharp edges

Signals & threads

Likely interview questions

Kernel Internals series. Related: Processes · Linux Troubleshooting.