Skip to content

Crack SDE

Most of the content are generated by AI, with human being reviewed, edited, and revised

Menu
  • Home
  • Daily English Story
  • Tech Interviews
  • Cloud Native
  • DevOps
  • Artificial Intelligence
Menu

Signals in Linux

Posted on 12/04/202312/07/2023 by user

Linux signals are a mechanism used for inter-process communication in Unix and Unix-like operating systems, such as Linux. They are used to notify a process that a specific event has occurred, such as an error, an external interrupt, or a software condition trigger.

How They Work

  1. Generation of Signal: Signals can be generated by the operating system kernel, a process (towards another process), or a user (through a terminal or tool).
  2. Sending Signal: Once generated, the signal is sent to the target process.
  3. Receiving Signal: Upon receiving a signal, the target process can take several different actions:
    • Execute the default signal handling behavior (such as terminating the process, ignoring the signal, etc.).
    • Catch the signal and execute a custom handler function.
    • Ignore the signal (some signals cannot be ignored).

Common Linux Signals

  • SIGINT (Signal number 2): Interrupt signal. When the user presses Ctrl+C, the terminal sends this signal to all processes in the foreground process group.
  • SIGTERM (Signal number 15): Termination signal. Typically used to request a program to exit gracefully.
  • SIGKILL (Signal number 9): Forceful termination signal. Used to immediately terminate a program and cannot be caught or ignored.
  • SIGSTOP (Signal number 17): Stop signal. Used to pause a program’s execution, also cannot be caught or ignored.
  • SIGSEGV (Signal number 11): Segmentation fault signal. Sent when a program tries to access illegal memory.
  • SIGHUP (Signal number 1): Hangup signal. Commonly used to notify a program that its configuration file has been changed and needs to be reloaded.
  • SIGUSR1 and SIGUSR2: User-defined signals, used for specific purposes in specific programs.
  1. SIGHUP (1): Hangup detected on controlling terminal or death of controlling process. Used to report that the user’s terminal is disconnected.
  2. SIGINT (2): Interrupt from keyboard (Ctrl+C). Used to terminate a program.
  3. SIGQUIT (3): Quit from keyboard (Ctrl+). Causes the process to terminate and produce a core dump.
  4. SIGILL (4): Illegal Instruction. Indicates a program is trying to execute an invalid instruction.
  5. SIGTRAP (5): Trace/breakpoint trap. Used by debuggers.
  6. SIGABRT (6): Abort signal from abort() system call.
  7. SIGBUS (7): Bus error. Indicates an invalid memory access.
  8. SIGFPE (8): Floating-point exception. Indicates an erroneous arithmetic operation, such as division by zero.
  9. SIGKILL (9): Kill signal. Forces the process to terminate immediately.
  10. SIGUSR1 (10): User-defined signal 1.
  11. SIGSEGV (11): Invalid memory reference. Indicates a segmentation fault.
  12. SIGUSR2 (12): User-defined signal 2.
  13. SIGPIPE (13): Broken pipe. Occurs when a process writes to a pipe with no readers.
  14. SIGALRM (14): Timer signal from alarm() system call.
  15. SIGTERM (15): Termination signal. Used to request a graceful shutdown of a process.
  16. SIGSTKFLT (16): Stack fault on coprocessor (not common on most architectures).
  17. SIGCHLD (17): Child stopped or terminated. Sent to a parent process when its child terminates or stops.
  18. SIGCONT (18): Continue if stopped. Instructs the operating system to continue (restart) a stopped process.
  19. SIGSTOP (19): Stop process. Causes the process to stop executing without terminating.
  20. SIGTSTP (20): Stop typed at terminal (Ctrl+Z). Requests a process to stop temporarily.
  21. SIGTTIN (21): Terminal input for background process. Sent to a background process attempting to read input from the terminal.
  22. SIGTTOU (22): Terminal output for background process. Sent to a background process attempting to write output to the terminal.
  23. SIGURG (23): Urgent condition on socket.
  24. SIGXCPU (24): CPU time limit exceeded.
  25. SIGXFSZ (25): File size limit exceeded.
  26. SIGVTALRM (26): Virtual alarm clock.
  27. SIGPROF (27): Profiling timer expired.
  28. SIGWINCH (28): Window resize signal.
  29. SIGIO (29): I/O now possible. Also known as SIGPOLL.
  30. SIGPWR (30): Power failure.
  31. SIGSYS (31): Bad system call. Also known as SIGUNUSED.

It’s important to note that not all signals can be caught, blocked, or ignored. For example, SIGKILL and SIGSTOP cannot be caught by the process. The behavior of signals can vary slightly between different Unix-like systems, but the above list is generally applicable to most Linux distributions.

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X

Related

Recent Posts

  • LC#622 Design Circular Queue
  • Started with OpenTelemetry in Go
  • How Prometheus scrap works, and how to find the target node and get the metrics files
  • How to collect metrics of container, pods, node and cluster in k8s?
  • LC#200 island problem

Recent Comments

  1. another user on A Journey of Resilience

Archives

  • May 2025
  • April 2025
  • February 2025
  • July 2024
  • April 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023

Categories

  • Artificial Intelligence
  • Cloud Computing
  • Cloud Native
  • Daily English Story
  • Database
  • DevOps
  • Golang
  • Java
  • Leetcode
  • Startups
  • Tech Interviews
©2025 Crack SDE | Design: Newspaperly WordPress Theme
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}