http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fapis%2Fsigpend.htm
Syntax
#include <signal.h>
int sigpending (sigset_t *set);
Service program NAME:QPOSSRV1
Default Public Authority: *use
Threadsafe:yes
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
Example
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);
}
Output:
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