Details about Python signals

Source: Internet
Author: User
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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.