The concept of signal (signal)-a means of communication between processes, is a software interruption. Once a process receives a signal, it will interrupt the original program execution process to process the signal. Several concepts of common signals
Signal: a means of communication between processes. it is a software interruption. Once a process receives a signal, it will interrupt the original program execution process to process the signal.
Several common signals:
SIGINT terminates the process to interrupt the process (control + c)
SIGQUIT exits the process
SIGTERM termination process software termination signal (default signal)
SIGKILL terminate the process and kill the process
SIGALRM alarm signal
For example, when you press control + c to terminate the process, the code is as follows:
Import signal
Def fun (sig, stack_frame ):
Print 'eixt % d, % s' % (sig, stack_frame)
Exit (1)
Signal. signal (signal. SIGINT, fun)
Signal. signal (signal. SIGINT, fun) is used to register the processing function of semaphores,
The first parameter is the semaphore, and the second parameter can be used to transmit a function,
This function has two parameters by default. The first parameter sig indicates the received semaphore, and the second stack_frame can be understood as the call stack that generates the interrupted semaphore sig.
The above is a detailed description of the Python signal. For more information, see other related articles in the first PHP community!