What does `SIGTERM` vs `SIGKILL` mean?

QuestionsQuestions8 SkillsProDec, 15 2025
0551

Excellent follow-up question! Those SIGTERM and SIGKILL signals are fundamental concepts in Linux process management, and understanding them is crucial, especially when you need to stop a misbehaving program.

You encountered them when I mentioned the F9 function in htop to kill a process. Let's break down what SIGTERM and SIGKILL mean:

What are Signals?

In Linux and Unix-like operating systems, signals are a form of inter-process communication (IPC). They are software interrupts sent to a program (a "process") to notify it of an event or to request it to perform a particular action. Think of them as messages sent to a program.

There are many different types of signals, each with a specific purpose (like SIGINT for interrupt, SIGHUP for hangup, etc.), but SIGTERM and SIGKILL are the most common ones you'll use for process termination.

1. SIGTERM (Signal 15: Terminate)

  • Meaning: "Please terminate gracefully."
  • Behavior: When a process receives a SIGTERM signal, it's a polite request to shut down. The process is given time to:
    • Perform cleanup operations (e.g., close open files, save unsaved data, release resources).
    • Exit its main loop.
    • Terminate itself in an orderly fashion.
    • The process can also ignore SIGTERM if it's programmed to do so, though well-behaved applications rarely do, or it might take a long time if it's heavily busy.
  • Analogy: Imagine you're wrapping up work for the day. Someone politely asks you to leave the office. You'd save your work, shut down your computer, clean your desk, and then head out.
  • When to use: This is your first choice when you want to stop a program. It's the "nice" way.

2. SIGKILL (Signal 9: Kill)

  • Meaning: "Terminate immediately, no questions asked."
  • Behavior: When a process receives a SIGKILL signal, the operating system's kernel immediately stops the process from executing.
    • The process has no opportunity to save data, close files, or perform any cleanup.
    • It cannot be caught, ignored, or blocked by the process. It's an unconditional termination.
  • Analogy: Imagine someone forces you out of the office in the middle of working, without letting you save files or clean up.
  • When to use: Use this as a last resort, typically when a process is unresponsive, frozen, or ignoring SIGTERM. While effective, it carries the risk of leaving behind temporary files, unsaved data, or an inconsistent state (though for most simple command-line tools, this isn't a huge concern).

Summary Table

Feature SIGTERM (Signal 15) SIGKILL (Signal 9)
Purpose Polite request to terminate and clean up Forceful, immediate termination
Catchable? Yes, process can catch, ignore, or handle No, process cannot catch, ignore, or block
Cleanup Process can perform graceful cleanup No cleanup by the process; kernel terminates immediately
Use Case First choice for terminating a process Last resort for unresponsive or "stuck" processes
Risk Low risk of data corruption Higher risk of data corruption or inconsistent state

How to use them (via kill command):

While htop gives you a menu, you can also send these signals directly from your terminal using the kill command (which often requires sudo if you're trying to kill another user's or a system process):

  • To send SIGTERM:
    kill <PID>
    # or
    kill -15 <PID>
    # or
    kill -SIGTERM <PID>
  • To send SIGKILL:
    kill -9 <PID>
    # or
    kill -SIGKILL <PID>
    (Remember, you'd replace <PID> with the actual Process ID number you see in htop or with ps -aux.)

Understanding SIGTERM vs. SIGKILL is a really practical skill for anyone managing processes in Linux. It allows you to troubleshoot and manage your system gracefully when possible, and forcefully when necessary.

Does that clarify the difference for you?

0 Comments

no data
Be the first to share your comment!