signal : communication mechanism between process and process
Signal is software interrupt
Signal is an asynchronous event
Signal Source: Kernel generation, common signal Kill (), raise (), Alarm (), SetTimer (), etc.
Kill-
View Linux all signals a total of 64 1-31 non-real-time signal send signal may be lost, does not support signal queuing
32-64 Real-time signal
Process processing Signal :
Ignore signal
Sigkill and sigstop can never be ignored.
Ignoring hardware exceptions
SIGUSER1 and SIGUSER2 Two signals are ignored during process startup
Perform the default action
Each signal has a default action, and most signal actions are termination signals.
Capture Signal
Tells the signal that the kernel is calling its own handler function.
Sigkill and Sigstop cannot be captured.
signal function signal Registration function void (*signal (int signo,void(*func) (int))) (int); parameter signo the signal value to be registered 1-thefunc signal handler function pointer /IGNORE signal sig_ign/ default signal sig_ Del returns SIG_ERR if the signal handler pointer is successfully returned
Labels
#include <unistd.h>#include<stdlib.h>#include<signal.h>#include<stdio.h>voidSet_signal (intSigno) {printf ("pid:%d,signo:%d\n", Getpid (), signo);}intMain () {//SIGTSTP is CTRL + Z if(Signal (sigtstp,set_signal) = =Sig_err) {printf ("Set signal Error"); } //Ctrl + C if(Signal (sigint,set_signal) = =Sig_err) {printf ("Set signal Error"); } intI=0; while(i< -) {printf ("I:%d\n", i++); Sleep (1); } return 0;}
The concept of signal of process and signal