Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

Section 10.13 sigpendingFunction 347


#include "apue.h"
#include <errno.h>

void
pr_mask(const char *str)
{
sigset_t sigset;
int errno_save;

errno_save = errno; /* we can be called by signal handlers */
if (sigprocmask(0, NULL, &sigset) < 0) {
err_ret("sigprocmask error");
}else {
printf("%s", str);
if (sigismember(&sigset, SIGINT))
printf(" SIGINT");
if (sigismember(&sigset, SIGQUIT))
printf(" SIGQUIT");
if (sigismember(&sigset, SIGUSR1))
printf(" SIGUSR1");
if (sigismember(&sigset, SIGALRM))
printf(" SIGALRM");

/* remaining signals can go here */

printf("\n");
}

errno = errno_save; /* restore errno */
}

Figure 10.14Print the signal mask for the process

To save space, we don’t test the signal mask for every signal that we listed in
Figure10.1. (See Exercise 10.9.)

10.13 sigpendingFunction


Thesigpendingfunction returns the set of signals that areblocked from delivery and
currently pending for the calling process. The set of signals is returned through theset
argument.

#include <signal.h>

int sigpending(sigset_t *set);

Returns: 0 if OK,−1 on error
Free download pdf