Skip to main content

Command Palette

Search for a command to run...

Which of the Following Represents a Signal in Linux

Updated
6 min read

When working with Linux, you often hear about "signals." But what exactly is a signal in Linux? If you’re new to Linux or programming on it, understanding signals is key to managing processes and handling events. Signals are a way the operating system communicates with running programs, telling them to stop, continue, or handle specific events.

In this article, I’ll explain what signals are in Linux, how they work, and which items represent signals. You’ll also learn about common signals, how to use them, and why they are important for system and application management. By the end, you’ll feel confident identifying and using signals in Linux.

What Is a Signal in Linux?

A signal in Linux is a limited form of inter-process communication (IPC). It’s a notification sent to a process or a group of processes to notify them that a specific event has occurred. Signals can interrupt a process to make it stop, continue, or perform a special action.

Signals are identified by names and numbers. For example, SIGINT (signal interrupt) is sent when you press Ctrl+C in the terminal. Each signal has a predefined meaning and default behavior.

How Signals Work

  • Signals are asynchronous, meaning they can arrive at any time.
  • When a signal is sent, the process can either handle it with a custom function (signal handler), ignore it, or perform the default action.
  • Some signals cannot be caught or ignored, such as SIGKILL and SIGSTOP.
  • Signals can be sent by the kernel, other processes, or the process itself.

Common Signals in Linux

Here are some common signals you’ll encounter:

Signal NameNumberDescription
SIGINT2Interrupt from keyboard (Ctrl+C)
SIGTERM15Termination request
SIGKILL9Kill signal (cannot be caught)
SIGSTOP19Stop process (cannot be caught)
SIGCONT18Continue a stopped process

These signals help control processes and manage system behavior.

Which of the Following Represents a Signal in Linux?

When you see a question like "Which of the following represents a signal in Linux?" the answer typically refers to the standard signal names or numbers defined by the system. Signals are usually represented by:

  • Signal names starting with SIG (e.g., SIGINT, SIGTERM)
  • Signal numbers (e.g., 2 for SIGINT, 15 for SIGTERM)

Examples of Signal Representations

  • SIGINT — a signal name representing an interrupt.
  • 9 — the signal number for SIGKILL.
  • SIGSTOP — a signal name to stop a process.
  • 15 — the signal number for SIGTERM.

If you are given options like these, the correct answer is the one that matches a valid signal name or number.

What Does Not Represent a Signal?

  • File names or paths.
  • Process IDs (PIDs).
  • Commands or options unrelated to signals.
  • Random numbers not assigned to signals.

How to List All Signals in Linux

If you want to see all signals available on your Linux system, you can use the kill command with the -l option:

kill -l

This command lists all signal names and their corresponding numbers. For example:

 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL
 5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE
 9) SIGKILL     10) SIGUSR1     11) SIGSEGV     12) SIGUSR2
13) SIGPIPE     14) SIGALRM     15) SIGTERM     16) SIGSTKFLT
...

This list helps you identify which signals exist and their numeric codes.

How to Send Signals in Linux

You can send signals to processes using the kill command. Despite its name, kill can send any signal, not just terminate processes.

Syntax

kill -SIGNAL_NAME PID

or

kill -SIGNAL_NUMBER PID

Examples

  • To send SIGINT to a process with PID 1234:
kill -SIGINT 1234
  • To send SIGKILL (force kill) to PID 1234:
kill -9 1234

This flexibility allows you to control processes precisely.

How Programs Handle Signals

When a process receives a signal, it can:

  • Perform the default action: For example, terminate or stop.
  • Ignore the signal: Some signals can be ignored.
  • Catch the signal: The program can define a signal handler function to run custom code.

Writing Signal Handlers

In programming languages like C, you can use the signal() function to define handlers. For example:

#include <signal.h>
#include <stdio.h>

void handle_sigint(int sig) {
    printf("Caught signal %d\n", sig);
}

int main() {
    signal(SIGINT, handle_sigint);
    while(1) {
        // Program runs until interrupted
    }
    return 0;
}

This program catches Ctrl+C (SIGINT) and prints a message instead of terminating immediately.

Why Are Signals Important in Linux?

Signals are crucial for:

  • Process control: You can stop, continue, or kill processes.
  • Inter-process communication: Processes can notify each other about events.
  • Handling asynchronous events: Like timers or hardware interrupts.
  • Graceful shutdown: Programs can clean up resources when receiving termination signals.

Without signals, managing processes and responding to system events would be much harder.

Summary Table: Common Linux Signals and Their Uses

Signal NameNumberDefault ActionTypical Use Case
SIGHUP1TerminateHangup detected, reload config
SIGINT2TerminateInterrupt from keyboard (Ctrl+C)
SIGQUIT3Core dump and terminateQuit from keyboard (Ctrl+)
SIGKILL9Terminate (cannot catch)Force kill a process
SIGTERM15TerminateGraceful termination request
SIGSTOP19Stop process (cannot catch)Pause a process
SIGCONT18Continue processResume a stopped process

How to Identify Signals in Multiple-Choice Questions

If you face a question like "Which of the following represents a signal in Linux?" here’s how to identify the correct answer:

  • Look for names starting with SIG followed by uppercase letters.
  • Check if the option is a known signal number (usually between 1 and 31).
  • Avoid options that are commands, file names, or unrelated terms.
  • Remember that signals are standardized and documented in Linux manuals (man 7 signal).

Practical Tips for Working with Signals

  • Use kill -l to list signals before sending them.
  • Use kill -SIGTERM PID for graceful shutdowns.
  • Use kill -SIGKILL PID only if the process doesn’t respond.
  • Write signal handlers in your programs to manage signals safely.
  • Avoid ignoring important signals like SIGTERM unless necessary.

Conclusion

Now you know that signals in Linux are special notifications sent to processes to control their behavior. They are represented by names like SIGINT or numbers like 9. Signals help manage processes, handle interrupts, and communicate events asynchronously.

When asked "Which of the following represents a signal in Linux?" look for the standard signal names or numbers. Understanding signals is essential for anyone working with Linux systems or programming on Linux. By mastering signals, you gain better control over processes and system behavior.


FAQs

What is the difference between SIGTERM and SIGKILL?

SIGTERM requests a process to terminate gracefully, allowing cleanup. SIGKILL forcefully stops a process immediately and cannot be caught or ignored.

Can all signals be caught or ignored by a process?

No. Signals like SIGKILL and SIGSTOP cannot be caught or ignored. Others can be handled or ignored by the process.

How do I list all signals available on my Linux system?

Run the command kill -l in the terminal to see all signal names and their numbers.

What happens if a process ignores a signal?

If a process ignores a signal, it continues running as if the signal was never sent, except for signals that cannot be ignored.

How do I send a signal to a process in Linux?

Use the kill command with the signal name or number and the process ID, for example, kill -SIGINT 1234 or kill -9 1234.

More from this blog

L

LinuxBloke | Linux Tips, Tricks & Troubleshooting

672 posts

Which of the Following Represents a Signal in Linux