In that year, I learned Linux C-Signal Set and Operations step by step.

Source: Internet
Author: User

This series of articles written by muge0913, reproduced please note the Source: http://blog.csdn.net/muge0913/article/details/7332372


In practical applications, an application needs to process multiple signals. For convenience, the concept of signal set is introduced in Linux. The signal set uses the sigset_t data type composed of multiple signals. The following system calls can be used to set the data contained in the signal set.


1. Common signals and definitions


2. sigset_t is defined in linux2.6.39/include/ASM-generic/signal. h.

typedef struct {     unsignedlong sig[_NSIG_WORDS];} sigset_t;


3. Corresponding System Call functions:

#include<signal.h>int sigemptyset(sigset_t *set);int sigfillset(sigset_t *set);int sigadd(sigset_t *set,int setnumber);int sigdelset(sigset_t *set,int setnumber);

Set indicates the signal set pointer, and setnumber indicates the signal.

Sigemptyset is used to set the signal set pointed to by the set to null, that is, it does not contain any signal.

Sigfillset is used to set the signal set to full to contain all signals.

Sigaddset is used to add signals to the signal set.

Sigdelset is used to delete signals from the signal set.

If the preceding functions are successful, 0 is returned. If the function fails,-1 is returned.

 

4. In addition, int sigismember (const sigset_t set, int signumber) is used to check whether signumber is in set. If it belongs to return 1, it does not return 0.


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.