SIGNAL NAME AND NUMBERS
1. Introduction
In the UNIX operating system, signals are one of the fundamental mechanisms used for communication
between processes and the operating system kernel.
A signal is a software interrupt — a message sent to a process to notify it that a specific event has
occurred. This could be a user action (like pressing Ctrl+C), a hardware exception (like segmentation
fault), or an internal system event (like timer expiration).
Each signal in UNIX is represented by both:
• A signal name (for human readability)
• A signal number (for internal identification by the kernel)
For example:
• SIGINT (Signal Interrupt) has the signal number 2
• SIGKILL (Kill Signal) has the signal number 9
Signals allow asynchronous communication — they can interrupt a running process anytime to handle
events immediately.
2. Concept of Signals in UNIX
A UNIX system may be running multiple processes simultaneously. The signal mechanism enables:
1. The kernel to inform a process of exceptional events (like division by zero or illegal memory
access).
2. Processes to communicate with each other — for example, to stop, resume, or terminate.
A process can:
• Send a signal using system calls like kill(), raise(), or pthread_kill().
• Receive and handle signals using functions like signal() or sigaction().
When a process receives a signal, it can:
• Perform the default action (terminate, stop, ignore, etc.)
• Ignore the signal
• Catch the signal and run a custom signal handler
3. Signal Names and Numbers Table in UNIX
UNIX defines a set of standard signals, each with a unique number and purpose. The table below lists
the most common signal names and numbers (for Linux/UNIX systems):
Signal Number Signal Name Description Default Action
1 SIGHUP Hangup detected on controlling terminal Terminate
2 SIGINT Interrupt from keyboard (Ctrl + C) Terminate
3 SIGQUIT Quit from keyboard (Ctrl + ) Core dump
4 SIGILL Illegal instruction Core dump
5 SIGTRAP Trace/breakpoint trap Core dump
6 SIGABRT Abort signal from abort() Core dump
7 SIGBUS Bus error (bad memory access) Core dump
8 SIGFPE Floating-point exception Core dump
9 SIGKILL Kill signal (cannot be caught or ignored) Terminate
10 SIGUSR1 User-defined signal 1 Terminate
11 SIGSEGV Invalid memory reference (segmentation fault) Core dump
12 SIGUSR2 User-defined signal 2 Terminate
13 SIGPIPE Broken pipe (write to pipe with no readers) Terminate
14 SIGALRM Timer signal from alarm() Terminate
15 SIGTERM Termination signal Terminate
17 SIGCHLD Child stopped or terminated Ignore
18 SIGCONT Continue if stopped Continue
19 SIGSTOP Stop process (cannot be caught or ignored) Stop
20 SIGTSTP Stop typed at terminal (Ctrl + Z) Stop
21 SIGTTIN Background process reading from terminal Stop
22 SIGTTOU Background process writing to terminal Stop
23 SIGURG Urgent condition on socket Ignore
24 SIGXCPU CPU time limit exceeded Core dump
25 SIGXFSZ File size limit exceeded Core dump
26 SIGVTALRM Virtual alarm clock Terminate
27 SIGPROF Profiling timer expired Terminate
28 SIGWINCH Window size change Ignore
Signal Number Signal Name Description Default Action
29 SIGIO I/O now possible Terminate
31 SIGSYS Bad system call Core dump
Note: Signal numbers may vary slightly across UNIX variants (Linux, macOS, BSD).
4. Types of Signals
a) User-Generated Signals
Generated manually by users or programs.
Examples:
• SIGINT (Ctrl + C)
• SIGQUIT
• SIGUSR1, SIGUSR2
b) Kernel-Generated Signals
Generated automatically by the kernel due to system or program errors.
Examples:
• SIGSEGV (invalid memory access)
• SIGFPE (divide by zero)
• SIGCHLD (child process terminated)
5. Signal Handling in UNIX
When a process receives a signal, UNIX follows these steps:
1. The signal is added to the process’s pending signal set.
2. The kernel checks the signal mask (whether the signal is blocked or allowed).
3. If unblocked, the signal is delivered to the process.
4. The process performs the default action, ignores, or executes a handler function.
Signal Handling Example (C Program):
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void handle_sigint(int sig) {
printf("\nCaught signal %d (SIGINT)\n", sig);
}
int main() {
signal(SIGINT, handle_sigint);
while (1) {
printf("Running...\n");
sleep(2);
}
return 0;
}
Explanation:
• When the user presses Ctrl+C, SIGINT (signal number 2) is sent.
• Instead of terminating, the program catches the signal and executes the custom handler.
6. Signal-Related Commands in UNIX
UNIX provides several commands to manage and observe signals:
Command Description
kill Sends a signal to a process (kill -9 PID)
killall Sends a signal to all processes by name
ps -l Shows signal-related process information
trap Used in shell scripts to catch or ignore signals
pkill Sends signals to processes matching a pattern
sleep Often combined with signals for timed execution
stty -a Displays terminal control signals
Examples:
kill -9 1234 # Forcefully kill process with PID 1234
kill -15 1234 # Gracefully terminate process
kill -SIGSTOP 1234 # Stop a process
kill -SIGCONT 1234 # Resume the stopped process
7. Signal Communication Between Processes
Signals allow simple interprocess communication (IPC).
Example:
• Parent process sends SIGUSR1 to child process to indicate completion.
• Child process catches this signal using a signal handler.
This approach is used in background daemons, servers, and shell scripts to coordinate tasks.
8. Special Signals
Some signals cannot be caught, blocked, or ignored:
Signal Description
SIGKILL (9) Immediately terminates the process
SIGSTOP (19) Suspends the process execution
These are reserved by the kernel for system-level control and ensure that a process cannot escape
termination or suspension.
9. Practical Applications
• Process Management: Stopping, resuming, and terminating programs.
• Error Handling: Handling memory access errors or floating-point exceptions.
• User Interrupts: Allowing users to interrupt running programs.
• Timers and Alarms: Using SIGALRM for timed events.
• Custom IPC: Developers use SIGUSR1 and SIGUSR2 for interprocess signaling.
• System Administration: Commands like kill and killall rely on signals.
10. Advantages
Advantage Description
Lightweight IPC Does not need shared memory or pipes
Fast Signals are delivered instantly
Kernel Supported Integrated deeply into UNIX architecture
Programmable Users can write custom handlers
Reliable Ensures system stability under unexpected conditions
11. Conclusion
Signal names and numbers in UNIX form a critical component of process control and interprocess
communication.
They allow the system and users to manage processes effectively — from graceful termination to
immediate force-kill operations.
Understanding the mapping between signal names (like SIGTERM, SIGKILL) and numbers (like 15,
9) is essential for programmers and administrators to handle processes safely and efficiently.
With the right usage of signals and handlers, UNIX systems can achieve reliable control, automation,
and error handling.