- What Is a Process Signal?
- Real-Life Use Case
- Common Process Signals You Should Know
- How to Send a Signal Using
kill
- Using
killall
for Convenience - Signals Aren’t Just for Crashing Things
- Conclusion
If you've ever wondered how you can stop a program in Linux, pause it, or even tell it to restart itself; you're talking about process signals. Think of signals like short messages sent from one part of the system to a program, telling it to do something specific.
This concept might sound technical, but once you get the hang of it, it's incredibly helpful; especially when a program is stuck or misbehaving.
What Is a Process Signal?
In Linux, a signal is a way to communicate with a process (a running program). It’s like sending a note that says, “Hey, do this!” or sometimes, “Hey, stop right now!”
Every process in Linux has a unique ID called a PID (Process ID), and you can send signals to that PID using built-in commands.
Common reasons you'd use signals include:
- Stopping unresponsive programs
- Gracefully asking a program to shut down
- Restarting background services
- Pausing or resuming tasks
Real-Life Use Case
Let’s say you're running a script that went into an endless loop and is eating up your computer’s resources. You could press Ctrl + C
to stop itbut what if it’s running in the background or on a remote server? That’s where signals come to the rescue.
By using a command like kill
, you can send a signal to the process and tell it, “Time’s up—shut down.” And don’t worry, despite the name, kill
isn’t always violent. Sometimes it's just a polite request.
Common Process Signals You Should Know
Here are the most common signals and what they do:
Signal | Name | Description |
---|---|---|
1 | SIGHUP | Tells a program to restart (often used for daemons) |
2 | SIGINT | Interrupts the process (like pressing Ctrl + C ) |
9 | SIGKILL | Forcefully kills the process—can’t be ignored |
15 | SIGTERM | Politely asks the process to terminate (default) |
18 | SIGCONT | Resumes a paused process |
19 | SIGSTOP | Pauses the process without killing it |
How to Send a Signal Using kill
Let’s look at a basic example.
-
Find the PID of the process
Use the
ps
orpidof
command:
ps aux | grep myprogram
pidof myprogram
-
Send a signal using
kill
:
kill -SIGTERM 1234
Or even more simply:
kill 1234
This sends a SIGTERM (signal 15), which is the default.
- Force kill (if the program ignores SIGTERM):
kill -9 1234
Using killall
for Convenience
Instead of using the PID, you can also send signals by name with killall
:
killall -SIGKILL firefox
This will force quit all instances of Firefox. Very handy when an app is totally frozen.
Signals Aren’t Just for Crashing Things
Not all signals are bad news! Some are meant to help programs behave better. For example:
- SIGHUP can make a server re-read its config file without stopping
- SIGSTOP and SIGCONT let you pause and resume tasks at will
It’s like having a remote control for your apps—you just need to know which button to press.
Conclusion
Signals are one of those Linux features that feel magical once you understand them. With just a few simple commands, you can take control of runaway processes, gently stop services, or automate routine tasks.
It may take a little practice, but once you get comfortable using process signals, you'll feel way more in control of your Linux system.
Want a quick cheat sheet or an example script that automates some of this? I'm happy to help. Just say the word.
Hey talented devs! If you’ve ever published on Dev.to, you may be eligible for free tokens. Head over here. for verified Dev.to users only. – Dev.to Airdrop Desk