Linux Signals — Process Communication and Control¶
Linux processes communicate with each other and with the operating system using signals. A signal is a software interrupt that notifies a process that an event has occurred. Signals are used to terminate, pause, resume, reload, or interrupt running processes. Understanding signals is essential for Linux administrators, DevOps engineers, Cloud Architects, and Site Reliability Engineers (SREs).
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand Linux signals
- Learn how processes communicate
- Identify common signals
- Send signals to processes
- Understand signal handling
- Use signals safely
- Troubleshoot applications using signals
- Apply signals in production environments
Prerequisites¶
Complete:
- Module 1 – Linux Fundamentals
- Module 2 – Linux Command Line Essentials
- Module 3 – Text Processing
- Module 4 – File Management and Permissions
- Module 5 – Users and Groups
- Module 6 Lessons 1–7
Why Learn Signals?¶
Imagine a production server where:
- An application stops responding.
- A web server needs to reload its configuration.
- A backup process must be paused.
- A database must shut down gracefully.
How does Linux communicate these requests?
The answer is Signals.
What is a Signal?¶
A signal is a software notification sent to a process.
It tells the process that something has happened or that it should perform a specific action.
Examples include:
- Stop running
- Pause execution
- Resume execution
- Reload configuration
- Interrupt execution
Signal Communication¶
The kernel delivers the signal, and the process reacts according to the signal type.
Signal Numbers and Names¶
Signals have both:
- A number
- A name
Example:
Both commands are equivalent:
List Available Signals¶
Display all supported signals.
Example:
Most Common Signals¶
| Signal | Number | Purpose |
|---|---|---|
| SIGHUP | 1 | Reload configuration or notify a process of terminal disconnection (behavior depends on the application) |
| SIGINT | 2 | Interrupt process (Ctrl + C) |
| SIGQUIT | 3 | Quit and generate a core dump |
| SIGKILL | 9 | Force immediate termination |
| SIGTERM | 15 | Graceful termination |
| SIGSTOP | 19 | Pause a process |
| SIGCONT | 18 | Resume a paused process |
SIGTERM¶
Gracefully terminate a process.
or
The process can:
- Save data
- Close files
- Release resources
This is the recommended method for stopping applications.
SIGKILL¶
Immediately terminate a process.
The kernel stops the process immediately.
The process cannot:
- Save data
- Close files
- Perform cleanup
Use only when necessary.
SIGINT¶
Generated by:
Example:
Press:
The application receives:
SIGSTOP¶
Pause a process.
The process stops execution but remains in memory.
SIGCONT¶
Resume a paused process.
The process continues execution from where it stopped.
SIGHUP¶
Many server applications interpret SIGHUP as a request to reload their configuration without restarting.
Example:
Common use cases include:
- Reloading web server configuration
- Refreshing logging configuration
- Reopening log files after rotation
Note
The exact behavior depends on how the application handles SIGHUP.
Signal Handling¶
Applications can choose to:
- Handle a signal
- Ignore certain signals
- Perform cleanup before exiting
However:
cannot be caught, blocked, or ignored by user-space applications.
Sending Signals¶
Graceful stop.
Force stop.
Pause.
Resume.
Reload configuration.
Common Commands¶
Display signals.
Graceful termination.
Force termination.
Pause.
Resume.
Real Production Examples¶
Reload NGINX configuration.
Terminate a hung Java application.
Pause a long-running batch process.
Resume processing.
Production Perspective¶
Signals are widely used for:
- Service management
- Configuration reloads
- Process termination
- Application maintenance
- Automation
- Incident response
- Deployment workflows
Many Linux services respond to signals without requiring a full restart.
Hands-on Lab¶
Task 1¶
Start a process.
Task 2¶
Find its PID.
Task 3¶
Pause the process.
Verify:
Observe the process state.
Task 4¶
Resume the process.
Task 5¶
Terminate gracefully.
Task 6¶
Start another process.
Task 7¶
Force termination.
Task 8¶
Display available signals.
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
kill -l | List signals | Signal reference |
kill PID | Send SIGTERM | Graceful shutdown |
kill -9 PID | Send SIGKILL | Force termination |
kill -STOP PID | Pause a process | Maintenance |
kill -CONT PID | Resume a process | Continue execution |
kill -HUP PID | Reload configuration | Web servers |
Production Troubleshooting Scenario¶
Scenario
An NGINX server receives an updated configuration.
Instead of restarting the service and interrupting client connections, the administrator reloads the configuration.
Result:
- Configuration is reloaded.
- Existing connections continue.
- Downtime is minimized.
This demonstrates why understanding signals is important for production operations.
Best Practices¶
- Use
SIGTERMbeforeSIGKILL. - Verify the PID before sending signals.
- Use
SIGHUPonly if the application supports configuration reloads. - Pause processes with
SIGSTOPonly when necessary. - Understand how critical applications respond to signals before using them in production.
Common Mistakes¶
❌ Using SIGKILL as the first option.
✅ Always try graceful termination first.
❌ Assuming every application reloads its configuration with SIGHUP.
✅ Behavior depends on the application's implementation.
❌ Sending signals to the wrong process.
✅ Always verify the PID and process name.
Interview Questions¶
Beginner¶
- What is a Linux signal?
- Which signal is sent by the
killcommand by default? - What does
Ctrl + Cgenerate? - Which command lists all available signals?
Intermediate¶
- What is the difference between
SIGTERMandSIGKILL? - What is the purpose of
SIGSTOPandSIGCONT? - Why can't
SIGKILLbe ignored? - When is
SIGHUPcommonly used?
Architect Level¶
- How would you reload a production web server without restarting it?
- Why should graceful termination always be preferred?
- How do Linux signals support zero-downtime operations?
Summary¶
In this lesson, you learned:
- Linux signals
- Process communication
- Common signals
- Signal handling
- Process control
- Configuration reloads
- Production best practices
Signals are a fundamental mechanism for communication between the Linux kernel, administrators, and running processes. They provide a flexible and efficient way to control application behavior without directly interacting with process internals.
Key Takeaways¶
- Signals are software interrupts sent to processes.
SIGTERMis the preferred method for graceful termination.SIGKILLimmediately terminates a process and should be used only when necessary.SIGSTOPpauses a process, whileSIGCONTresumes it.- Many applications use
SIGHUPto reload configuration. - Understanding signals is essential for Linux administration and production operations.
What's Next?¶
systemd — Managing Services and System Initialization in Linux
You'll explore:
- What
systemdis - The boot process
- Units and targets
- Managing services
- Viewing system status
- Boot-time service management
- Enterprise system administration
systemd is the default init system on most modern Linux distributions and is responsible for managing services, system startup, and background processes.