Signal:
1. Initially introduced as user-state interprocess communication
2. The kernel also uses signals to notify events that occur in the process system
3, the signal is very short, the only information sent to the process is usually a number.
4. The name is usually prefixed with the sig
5, the signal can consume resources, each signal can only be transmitted once
Target of using signal:
1. Let the process know that a specific event has been sent
2, forcing the process to execute its own code in the Signal processing program.
There are two types of signals:
1, conventional signal (regular signal): Coding Range (0~31), the same type of conventional signals are not queued, a conventional signal is sent multiple times, only one of them is received.
2, real-time signal (real-time signal): Encoding range (32~64), need to queue so that multiple signals can be received
3. The Linux kernel does not use real-time signals.
Two different stages of signal transmission:
1. Signal generation: The kernel updates the data structure of the target process to indicate that a new signal has been issued.
2, signal transmission: The kernel forces the target process to respond to the signal by: A, change the execution status of the target process; b. Start a specific signal processing program; C, both.
Suspend signal (pending signal):
1, has been produced has not been transmitted to the signal;
2. At any time a process has only one pending signal of a given type; the same other signals are not queued, simply discarded
3, if the real-time signal, the same type of hang signal can have several, it supports queuing.
Signal Processing Program:
1, do not have to be re-entered, the same type of signal again will not interrupt the ongoing signal processing program, it will be blocked.
Three ways the process responds to signals:
1, explicitly ignore the signal
2, the implementation of the signal-related default operation terminate, dump, ignore, stop, continue.
3, by invoking the corresponding signal processing function to capture the signal.
Differences in signal blocking and ignoring:
1, the signal is blocked, it will not be transmitted, only unblocked after the transmission
2, the signal is ignored, it is still passed, just not processed
SIGKILL, SIGSTOP These two signals cannot be blocked, ignored, captured, and the received processes must perform their corresponding default actions.
Deep understanding of the Linux kernel-signal