Linux under C Programming: Signal processing methods && practical applications

Source: Internet
Author: User
Tags linux

The signal is used for a one-step event. When a signal occurs, the program performs the appropriate operation according to the programmed program.

There are two ways in which processes can be used for signal processing:

1, capture signal: When a signal to send a process, the process will call this signal registration signal processing function, to complete the corresponding operation. Each signaling system typically has a corresponding default handler function (typically the terminating process). So you can set the signal as the default handler function.

2, ignore the signal. When the signal is sent, the process ignores the signal.

Note: There are two signals that cannot be captured and ignored by Sigkill and Sigstop. They are provided to the administrator and can be set at any time to terminate a process.

Signal processing requirements: Sometimes the process needs to respond to a signal immediately when the user is programming. For some real-time processes, when it is executed it is unwilling to be interrupted, and this is the need to suspend the received signal.

Use of the signal:

One of the most common applications of a signal is that the notification process ends when an error occurs. For many errors, such as bus errors, floating-point errors, calling memory errors, etc., there is a corresponding signal notification process.

Besides, there are other uses for the signal. If you run a large scientific computing program, if you use printf in an infinite loop to display the running state, it is bound to cause a decline in operational efficiency. So through the signal, artificial to the process to send messages to view the running state, greatly improve the operational efficiency.

View a full set of articles: Http://www.bianceng.cn/Programming/C/201212/34807.htm

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.