Understanding Linux Process Signals: A Complete Guide for Beginners

Linux process signals are short notifications the kernel or another process sends to a running process. The ones you use most are SIGTERM (15) to ask a process to stop, SIGKILL (9) to force it, and SIGHUP (1) to hang up or reload. Send them with kill, pkill or killall, and catch them in shell scripts with trap.
This guide covers the common signals, how to send and inspect them, and how to troubleshoot processes that don’t react. It builds on our previous guide on Linux Process Management.
Short version
kill -l # list signal names and numbers
kill <PID> # send SIGTERM (15), the default
kill -HUP <PID> # send SIGHUP (1), many daemons reload their config
kill -9 <PID> # send SIGKILL, last resort, no cleanup
pkill -TERM firefox # signal processes by name
trap 'echo "cleaning up"; exit 1' INT TERM # handle signals in a bash scriptTable of Contents
- Short version
- What Are Process Signals?
- Common Linux Signals
- SIGTERM (Signal 15)
- SIGKILL (Signal 9)
- SIGHUP (Signal 1)
- Working with Process Signals
- Sending Signals
- Listing Available Signals
- Signal Handling Best Practices
- 1. Use SIGTERM First
- 2. Process Group Management
- 3. Signal Monitoring
- Common Use Cases
- Service Management
- Application Control
- Troubleshooting Common Issues
- Zombie Processes
- Signal Permission Errors
- Advanced Signal Concepts
- Real-time Signals
- Signal Masking
- Best Practices for System Administrators
- FAQ
- What is the difference between SIGTERM and SIGKILL?
- Why won't kill -9 kill a process?
- How do I handle signals in a bash script?
- Which signal does Ctrl+C send?
- Conclusion
What Are Process Signals?
Process signals are software interrupts that provide a way to handle asynchronous events. Think of them as messages that processes receive to notify them about specific events or to request certain actions. These signals help maintain order and control in the Linux operating system.
Common Linux Signals
SIGTERM (Signal 15)
SIGTERM is the polite way to ask a process to terminate. When a process receives this signal, it:
- Has time to clean up resources
- Can save data if needed
- Performs an orderly shutdown
kill -15 <PID>SIGKILL (Signal 9)
SIGKILL is the forceful termination signal that:
- Cannot be caught, blocked or ignored by processes
- Terminates the process as soon as the kernel delivers it
- Doesn’t allow cleanup operations
kill -9 <PID>SIGHUP (Signal 1)
Traditionally used to notify about terminal disconnection, SIGHUP now often serves to:
- Reload configuration files
- Restart processes
- Reinitialize applications
kill -1 <PID>Working with Process Signals
Sending Signals
The kill command is the primary tool for sending signals:
# Send SIGTERM to process 1234
kill 1234
# Send specific signal (SIGHUP) to process 1234
kill -1 1234
# Send SIGTERM to the processes named process_name that a specific user owns
killall -u username process_nameListing Available Signals
View all available signals on your system:
kill -lSignal Handling Best Practices
1. Use SIGTERM First
Always try SIGTERM before SIGKILL:
# First attempt
kill <PID>
# If process persists after a few seconds
kill -9 <PID>2. Process Group Management
Manage multiple related processes:
# Send signal to process group
kill -TERM -<PGID>3. Signal Monitoring
Monitor process signal handling:
# Show signals received and signal-related system calls
strace -e trace=%signal -p <PID>Common Use Cases
Service Management
Reload system services gracefully. For nginx, SIGHUP goes to the master process, which reloads its configuration and replaces its worker processes:
# Find the nginx master PID (the oldest nginx process)
pgrep -o nginx
# Send SIGHUP to the master to reload configuration
kill -HUP $(pgrep -o nginx)On a systemd server, sudo systemctl reload nginx does the same job and is the usual way.
Application Control
Manage running applications:
# Gracefully terminate an application
pkill -15 firefox
# Force quit if unresponsive
pkill -9 firefoxTroubleshooting Common Issues
Zombie Processes
Zombie processes occur when parent processes don’t properly handle child process termination. A zombie has already exited, so no signal removes it. Signal or restart its parent instead:
# Identify zombie processes (state Z)
ps -eo pid,ppid,stat,cmd | awk '$3 ~ /^Z/'
# Find parent of zombie process
ps -o ppid= -p <ZOMBIE_PID>Signal Permission Errors
Handle permission-related signal issues:
# Check process ownership
ps -o user= -p <PID>
# Use sudo for privileged processes
sudo kill <PID>Advanced Signal Concepts
Real-time Signals
Linux provides real-time signals (SIGRTMIN to SIGRTMAX) for application-specific use:
# Send real-time signal
kill -RTMIN+1 <PID>Signal Masking
Processes can temporarily block signals:
# Check blocked (SigBlk), ignored (SigIgn) and caught (SigCgt) signals
grep -E 'SigBlk|SigIgn|SigCgt' /proc/<PID>/statusBest Practices for System Administrators
- Document signal usage in your environment
- Implement proper logging for signal events
- Create standard procedures for process termination
- Regular audit of process signal handling
- Test signal handling during application deployment
FAQ
What is the difference between SIGTERM and SIGKILL?
SIGTERM (15) asks a process to stop. The process can catch it, save its work and exit cleanly. SIGKILL (9) cannot be caught, blocked or ignored, so the kernel ends the process without any cleanup. Send SIGTERM first and use SIGKILL only when the process doesn’t exit.
Why won’t kill -9 kill a process?
Check the process state with ps -o pid,stat,cmd -p <PID>. State Z means it’s a zombie: it has already exited and waits for its parent to reap it, so signal or restart the parent. State D means uninterruptible sleep, usually waiting on I/O such as a hung NFS mount, and the process only dies once that I/O returns.
How do I handle signals in a bash script?
Use the trap builtin with a command and the signal names without the SIG prefix, for example trap 'rm -f /tmp/lockfile; exit 1' INT TERM. Use trap cleanup EXIT to run a cleanup function whenever the script exits. You cannot trap SIGKILL or SIGSTOP.
Which signal does Ctrl+C send?
Ctrl+C sends SIGINT (2) to the foreground process. Ctrl+\ sends SIGQUIT (3), whose default action also writes a core dump, and Ctrl+Z sends SIGTSTP (20) to suspend the process. Resume a suspended job with fg or bg.
Conclusion
Understanding Linux process signals is essential for effective system management. Start with basic signals like SIGTERM and gradually explore more advanced concepts as you become comfortable with process control.
Practice these concepts in a safe environment before implementing them in production. Remember that proper signal handling is crucial for maintaining system stability and reliability.
For more advanced Linux system management topics, check out our guide on Linux Memory Management, which complements this knowledge of process control.
More posts
All Linux

