Junior
What signal is sent when using the kill command: SIGTERM or SIGKILL?
sobes.tech AI
Answer from AI
When using the kill command without specifying a signal number or name, the default signal sent is SIGTERM.
SIGTERM (Terminate Signal):
- This is a gentle termination signal.
- It requests the process to terminate gracefully.
- The process can catch this signal, perform cleanup (close files, save state), and then exit, or ignore it.
SIGKILL (Kill Signal):
- This is a "hard" termination signal.
- It cannot be caught or ignored by the process.
- The system immediately terminates the process without giving it a chance to clean up.
Thus, kill by default sends SIGTERM. To send SIGKILL, you need to specify it explicitly:
# Send SIGTERM (default)
kill <PID>
# Send SIGKILL
kill -9 <PID>
# or
kill -s SIGKILL <PID>