$RodHat_/search

$ man 7 signal · diff

SIGTERM vs SIGKILL

Which one should stop a process?

Start with SIGTERM. It asks the process to exit and leaves room for a handler to clean up. SIGKILL ends it without running a handler. Use SIGKILL when the process has not responded and waiting longer is worse.

FieldSIGTERMSIGKILL
Linux number159
FreeBSD number159
Default actionTerminate the processTerminate the process
Catch, block or ignoreYesNo

SIGTERM

The default action is termination, but a process may catch, block or ignore SIGTERM. That gives a server a chance to close connections and write out state. It also means a broken handler can leave the process running.

SIGKILL

SIGKILL cannot be caught, blocked or ignored. It does not give userspace a cleanup pass. Even SIGKILL cannot complete while a task is stuck in uninterruptible I/O sleep; the pending signal takes effect when the task can run again.

Rod's field note

A shutdown procedure needs a deadline, not a blind loop of kill -9. Send TERM, wait for exit, then escalate if it is still there. If it remains in D state, investigate the I/O path instead of sending the same signal again.

What to check

If the process survives TERM, check whether it installed a handler, whether a wrapper forwards signals, and whether the task is in uninterruptible sleep.

Sources and scope

Default actions and Linux numbers follow signal(7). FreeBSD numbers follow the FreeBSD signal(3) manual. Numbers shown are Linux x86/arm64 and FreeBSD; other Linux architectures may differ. Installed handlers can change observed behavior except for signals that cannot be caught.

← More signal comparisons