sigpending -- Return Pending Signals

SYNOPSIS

 #include <lcsignal.h>

 int sigpending(sigset_t *set);
 
The synopsis for the POSIX implementation is
 #include <signal.h>

 int sigpending(sigset_t *set);
 
You should use <signal.h> only if an appropriate feature test macro has been defined.

DESCRIPTION

sigpending returns the signals that are currently pending. The signal numbers are stored in the signal set addressed by set.

The sigpending function tests for pending signals (signals that have been generated for the process, but not delivered). In a POSIX system without extensions, a signal can be pending only if the signal is blocked. Some SAS/C extensions can delay delivery of one or more signals, even though the signal is not blocked. Any such delayed signals are included in the set of pending signals stored by sigpending.

RETURN VALUE

sigpending returns 0 if it is successful and - 1 if it is not successful.

EXAMPLE

  #include <signal.h>
  #include <stdio.h>

     /* Define structure of POSIX signal names and numbers. */
  const struct {
     int signum;
     char *signame;
  } sigtable[] = {
     {SIGABRT, "ABRT"},
     {SIGALRM, "ALRM"},
     {SIGCHLD, "CHLD"},
     {SIGCONT, "CONT"},
     {SIGFPE,  "FPE"},
     {SIGHUP,  "HUP"},
     {SIGILL,  "ILL"},
     {SIGINT,  "INT"},
     {SIGKILL, "KILL"},
     {SIGPIPE, "PIPE"},
     {SIGQUIT, "QUIT"},
     {SIGSEGV, "SEGV"},
     {SIGSTOP, "STOP"},
     {SIGTERM, "TERM"},
     {SIGTSTP, "TSTP"},
     {SIGTTIN, "TTIN"},
     {SIGTTOU, "TTOU"},
     {SIGUSR1, "USR1"},
     {SIGUSR2, "USR2"}};

  void show_pending(void) {
     sigset_t sigset;
     int i;
     int count;

     if (sigpending(&sigset) != 0)
        perror("sigpending error");
     else {
        count = 0;            /* Initialize pending count.  */
        for(i = 0; i < sizeof(sigtable)/sizeof(sigtable[0]); ++i)
           if (sigismember(&sigset, sigtable[i].signum)) {
              printf("Signal SIG%s is pending.", sigtable[i].signame);
              ++count;
           }
        if (count == 0)       /* if no signals were pending */
           puts("No POSIX signals are pending.");
     }
  }

 

RELATED FUNCTIONS

sigaddset, sigprocmask

SEE ALSO


Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.