sigprocmask

Sets the current signal mask.

Format

#include  <signal.h>

int sigprocmask  (int how, const sigset_t *set,
                 sigset_t *o_set);

Arguments

how
An integer value that indicates how to change the set of masked signals. Use one of the following values:
SIG_BLOCK   The resulting set is the union of the current set and the signal set pointed to by the set argument. 
SIG_UNBLOCK   The resulting set is the intersection of the current set and the complement of the signal set pointed to by the set argument. 
SIG_SETMASK   The resulting set is the signal set pointed to by the set argument. 
set
The signal set. If the value of the set argument is:
o_set
A non-NULL pointer to the location where the signal mask in effect at the time of the call is stored.

Description

This function is used to examine or change the signal mask of the calling process.

Typically, use the sigprocmask SIG_BLOCK value to block signals during a critical section of code, then use the sigprocmask SIG_ SETMASK value to restore the mask to the previous value returned by the sigprocmask SIG_BLOCK value.

If there are any unblocked signals pending after the call to the sigprocmask function, at least one of those signals is delivered before the sigprocmask function returns.

You cannot block SIGKILL or SIGSTOP signals with the sigprocmask function. If a program attempts to block one of these signals, the sigprocmask function gives no indication of the error.

Example

    The following example shows how to set the signal mask to block only the SIGINT signal from delivery:

      #include <signal.h>
    
      int return_value;
      sigset_t newset;
       . . .
      sigemptyset(&newset);
      sigaddset(&newset, SIGINT);
      return_value = sigprocmask (SIG_SETMASK, &newset, NULL);
    

Return Values
Indicates success. 
-1  Indicates an error. The signal mask of the process is unchanged. errno is set to one of the following values:

  • EINVAL - The value of the how argument is not equal to one of the defined values.

  • EFAULT - The set or o_set argument points to a location outside the allocated address space of the process.
 


Previous Page | Next Page | Table of Contents | Index