Sigpending ()--examine Pending signals

Source: Internet
Author: User


#include <signal.h>

 int sigpending (sigset_t *set);  

Service program NAME:QPOSSRV1

Default Public Authority: *use


The sigpending () function returns signals that are blockedfrom delivery and pending for either thread or the process. Thisinformation is represented as a signal set stored in set. For moreinformation on examining the signal set pointed to by set, and the "to Sigismember" ()--test for signal in signal set.
Parameters *set (Output) A Pointer to the where the signal set information isstored.
return Value

0 sigpending () wassuccessful.
-1 sigpending () is not successful. The errno variable is set to indicate the error.

Error Conditions

If sigpending () is not successful, errno usuallyindicates the following error. Under some conditions, errno couldindicate an error, and than that listed. [Enotsiginit]

The Process not is enabled for signals.

An attempt being made to call a signal function under one of the followingconditions:the signal function is being called fo R a process that's not enabled forasynchronous signals.

The signal function is being called the system signal controls havenot been.
Related Information The <signal.h> file (headerfiles for unix-type functions)

Sigaddset ()--add Signal to Signal Set

Sigdelset ()--delete Signal from Signal Set

Sigemptyset ()--initialize and Empty Signalset

Sigfillset ()--initialize and Fill Signal Set

Sigismember ()--test for Signal in Signal Set

Sigprocmask ()--examine and change blockedsignals

Disclaimer InformationFor Information pertaining to code examples.

The following example returns blocked and pending signals:

#include <signal.h> #include <unistd.h> #include <stdio.h> void catcher (int sig) {puts ("inside
Catcher () function\n ");

    } void check_pending (int sig, Char *signame) {sigset_t sigset;

    if (sigpending (&sigset)!= 0) perror ("sigpending () error\n");
         else if (Sigismember (&sigset, SIG)) printf ("A%s signal is pending\n", signame);
else printf ("No%s signals are pending\n", signame);
    int main (int argc, char *argv[]) {struct sigaction sigact;

    sigset_t Sigset;
    Sigemptyset (&sigact.sa_mask);
    sigact.sa_flags = 0;

    Sigact.sa_handler = catcher;

    if (Sigaction (SIGUSR1, &sigact, NULL)!= 0) perror ("Sigaction () error\n");
        else {sigemptyset (&sigset);
        Sigaddset (&sigset, SIGUSR1);

       if (Sigprocmask (Sig_setmask, &sigset, NULL)!= 0) perror ("Sigprocmask () error\n");
        else {    printf ("SIGUSR1 signals are now blocked\n");
            Kill (Getpid (), SIGUSR1);

            printf ("after Kill () \ n");

            Check_pending (SIGUSR1, "SIGUSR1");
            Sigemptyset (&sigset);
            Sigprocmask (Sig_setmask, &sigset, NULL);

            printf ("SIGUSR1 signals are no longer blocked\n");
        Check_pending (SIGUSR1, "SIGUSR1");
} return (0);

    SIGUSR1 signals are now blocked after
    kill ()
    a SIGUSR1 signal is pending
    inside catcher () function
    sigusr 1 signals are no longer blocked
    no SIGUSR1 signals are pending

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: 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.