Linux interprocess communication (v) signal of Signal communication (), Signal Set function group and its basic experiment

Source: Internet
Author: User
Tags function prototype signal handler

In the previous section, one of the ways of interprocess communication is the signal generation and capture function in signal communication, this section introduces the signal () function and the SET function group of signal processing functions, and then a section http://blog.csdn.net/mybelief321/article/details/9078193

It is highly recommended to do a final experiment!

Signal Processing method

The signal processing method mainly has the following two kinds:

① uses the signal () function;

② uses a set of signal set functions.

Using the signal () function

Function description

When you use the signal () function, you simply point to the signal and the processing function that you want to work with. It is mainly used in the first 32 kinds of non real-time signal processing, and does not support signal transmission information. Linux also supports a more robust update of the signal processing function, which is sigaction (), and is recommended for use in this function.

function format

Here signal () the prototype of this function I looked at the head a bit large, or to explain first: first of all, the function prototype points to a function pointer without a return value and with an integer parameter, which is the original configuration function of the signal, and then the prototype has two parameters, of which the 2nd A parameter can be a function pointer to a user-defined signal processing function. Do not understand also nothing, behind the experiment will understand, will be used on the line.

Here is a description of the sigaction structure used for the 2nd and 3rd parameters in the Sigaction () function, and the following table defines the siaction:

Sa_handler is a function pointer that specifies the signal processing function, which can be used in addition to our custom processing functions, either for SIG_DFL (with default processing) or for sig_ign (ignoring the signal). Its handler function has only one parameter, namely the signal value.

Sa_mask is a set of signals that specifies which signals should be masked during the execution of a signal handler, and that the signal set is added to the signal mask word before the signal capture function is invoked.

The sa_flags contains a number of flag bits, which are the various options for processing the signal. Its common optional values are shown in the following table:

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.