Today I discovered a simple but important improvement to using the kill
command that makes process management safer and more readable.
Using Readable Signal Names
Instead of memorizing and using numeric signal codes, the kill
command accepts human-readable signal names:
Traditional Numeric Approach:
|
|
Better Readable Approach:
|
|
Common Signal Names
Process Termination:
-TERM
(15): Polite termination request - allows cleanup-KILL
(9): Immediate forceful termination - no cleanup possible-QUIT
(3): Quit with core dump for debugging
Process Control:
-STOP
(19): Pause process execution (cannot be caught or ignored)-TSTP
(20): Terminal stop signal (Ctrl+Z equivalent)-CONT
(18): Resume stopped process execution
Application Signals:
-HUP
(1): Hangup - often used to reload configuration-USR1
(10): User-defined signal 1 - application-specific behavior-USR2
(12): User-defined signal 2 - application-specific behavior
Benefits of Readable Names
Safety and Clarity:
|
|
Self-Documenting Scripts:
|
|
Reduced Errors:
Using readable names eliminates the risk of accidentally using the wrong signal number, which could have unintended consequences on system stability.
This simple practice makes process management commands more maintainable and reduces the cognitive load of remembering numeric signal codes.