title: Iterating over a list of possible signals
body: <p>I have some code that I want to use to print a list of signals that prints the names of the signals in the signal mask of the calling process.</p>
  
  <p>The starting code that I have is below:</p>
  
  <pre><code>#include "apue.h" 
  #include &lt;errno.h&gt; 
  
  void 
  pr_mask(const char *str) 
  { 
      sigset_t sigset; 
      int errno_save;     
  
      errno_save = errno; 
  
      if (sigprocmask(0, NULL, &amp;sigset) &lt; 0) { 
          err_ret("sigprocmask error"); 
      }else { 
          printf("%s", str); 
          if (sigismember(&amp;sigset, SIGINT)) 
              printf(" SIGINT"); 
          if (sigismember(&amp;sigset, SIGQUIT)) 
              printf(" SIGQUIT"); 
          if (sigismember(&amp;sigset, SIGUSR1)) 
              printf(" SIGUSR1"); 
          if (sigismember(&amp;sigset, SIGALRM)) 
              printf(" SIGALRM"); 
          printf("\n");
      } 
      errno = errno_save; 
  }
  </code></pre>
  
  <p>The thing is, I want to do more signals than just <code>SIGINT</code>, <code>SIGQUIT</code>, <code>SIGUSR1</code> and <code>SIGALRM</code>. I do not want to make a long list of if statements for each alarm.</p>
  
  <p>I want to do something like this:</p>
  
  <pre><code>for(int i = 0; i &lt; 32; i++) {
       printf("%s", str)
       if(sigismember(sigset, signal_array[i]))
          printf("%s", signal_array[i]);
  }
  </code></pre>
  
  <p>Where <code>signal_array</code> is something like this:</p>
  
  <pre><code>signal array[32] {
      SIGINT, "SIGINT"
     ...
     ...
     ... 
  }
  </code></pre>
  
  <p>Is there some way I can do this so it is easier for me to print out each signal? It would simplify things a lot.</p>