Types of Signals
- SIGHUP- This signal indicates that the controlling terminal has been killed. HUP is an abbreviation meaning “hang up.” Locate the terminal to be controlled or hang up on the control process’s demise. This signal is obtained when the process is performed from the terminal and that terminal abruptly terminates.
- SIGINT- This is the signal generated when a user presses Ctrl + C from the keyboard.
- SIGQUIT- This is the signal generated when a user presses Ctrl + D from the keyboard.
- SIGILL- Signal for illegal instruction. This is an exception signal provided by the operating system to your application when it detects unlawful instruction within your program. For example, if some code is not understandable by your machine or if your program’s executable file is corrupted. Another possibility is that your program loads a corrupted dynamic library.
- SIGABRT- Abort signal indicates that you used the abort() API within your program. It is used to end a program. abort() generates the SIGABRT signal, which terminates your program (unless handled by your custom handler).
- SIGFPE- Exception for floating point numbers. Another exception signal is generated by the operating system when your program causes an exception.
- SIGPIPE- Broken pipe. When there is nothing to read on the other end, write to the pipe.
- SIGSEGV- This is also an exception signal. When a program tries to access memory that does not belong to it, the operating system gives that application this signal.
- SIGALRM- Alarm Signal sent through the alarm() system function to your program. The alarm() system call essentially acts as a timer that allows you to receive SIGALRM after a set amount of time. Although there are other timer APIs that are more accurate, this can be useful.
- SIGTERM- This signal instructs your program to quit. While SIGKILL is an abnormal termination signal, think of this as a signal to cleanly shut down.
- SIGCHLD- Informs you that a child’s process of your program has ended or stopped. This is useful if you want to synchronize your process with one that has children.
- SIGUSR1 and SIGUSR2- SIGUSR1 and SIGUSR2 are two undefined signals that are provided for your consideration. These signals can be used to communicate with or synchronize your software with another program.
Signal Handling In Linux Through The signal() Function
A signal is a message or notification issued to your program by the operating system or another application (or one of its threads). Each signal is assigned a number between 1 and 31. Signals are devoid of argument, and most of the time, their names are self-explanatory. For instance, signal number 9 or SIGKILL notifies the program that it is being attempted to be killed.
Contact Us