Linux under C Programming: signal set and operation

Source: Internet
Author: User
Tags definition linux

In a practical application, one application needs to handle multiple signals, and in order to be convenient, the Linux system introduces the concept of the signal set. A data type sigset_t with multiple signals. The following system calls can be used to set the data contained in the signal set.

1, the common signal and definition as shown:

2, sigset_t in the linux2.6.39/include/asm-generic/signal.h definition

typedef struct {

     unsignedlong sig[_nsig_words];
           
} sigset_t;

3, the corresponding system call function:

#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 represents a signal set pointer, Setnumber represents a signal.

Sigemptyset is used to set the set of signals that the set points to null, that is, to not contain any signals.

Sigfillset is used to set the set of signals that the set points to full, that is, to contain all the signals.

Sigaddset is used to add a signal to a signal set.

Sigdelset is used to remove signals from the signal set.

The above function successfully returns 0, failure returns-1

4, in addition, the int sigismember (const sigset_t set,int signumber) is used to detect whether the signumber is in set, if it belongs to return 1, not return 0.

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.