Chapter Contents

Previous

Next
sigsetmask

sigsetmask



Inhibit or Permit Discovery of Signals

Portability: UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
PORTABILITY
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <lcsignal.h>

int sigsetmask(int mask);


DESCRIPTION

sigsetmask blocks or unblocks one or more asynchronous signals. The mask argument is an integer interpreted as a bit string, with each bit corresponding to a particular signal. You use this bit string to specify a mask of blocked signals.

For example, the following call blocks the SIGALRM signal and unblocks all other signals:

sigsetmask(1<<(SIGALRM - 1));

You can use the same format to block any single asynchronous signal; simply change the name of the signal to be blocked. To unblock all signals, use sigsetmask(0) .

The SAS/C library honors only bits corresponding to the asynchronous signals (SIGINT, SIGALRM, SIGIUCV, and SIGASY1 through SIGASY8); any other bits set in the mask are ignored. Also, sigsetmask does not affect any signals managed by USS. For this reason, sigprocmask , which can be used for all signals, is preferable to sigsetmask .

If a signal occurs while it is blocked, the signal is kept pending until it is unblocked by a call to sigsetmask or sigpause . When the signal is unblocked, it is discovered, and the appropriate handler is called. When a program begins executing, no signals are blocked. Refer to Blocking Signals for more information.

For compatibility with previous releases, a call to sigsetmask requesting that all signals be blocked (a signal mask of all ones) causes all blockable USS signals to be blocked as well. This blocking occurs within the library, so if you call sigbsetmask(0xffffffff) and then use an exec function to transfer control to another program, that program receives control with no signals blocked.


RETURN VALUE

sigsetmask returns the previous mask of blocked signals. You can pass this value to sigsetmask later to restore the previous mask. Bits of the mask corresponding to synchronous signals are always 0.


CAUTION

You should not keep signals blocked for long periods of time because this may use large amounts of memory to queue pending signals. For lengthy programs, you should use sigblock to protect critical sections of the program and then reset the mask with sigsetmask to allow signals to occur freely in less critical areas.

The library sometimes blocks signals to delay asynchronous signals during its own processing. If the library is in the middle of processing and something occurs that causes it to call longjmp to return to your program, the mask set by the library may still be in effect; that is, the mask may not be what you specified in your program. For example, suppose a library function runs out of stack space and raises SIGMEM, and the handler for SIGMEM returns to your program with a longjmp . You may need to issue sigsetmask at the completion of the jump to restore the signal mask needed by the program. The functions sigsetjmp and siglongjmp may be useful in these situations.

A signal generated by the program calling raise or siggen always occurs immediately, even if the signal is blocked.


PORTABILITY

sigsetmask is only portable to BSD-compatible UNIX operating systems.


EXAMPLE

Refer to the example for sigblock .


RELATED FUNCTIONS

sigblock , sigpause , sigprocmask


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.