DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Signals, job control and pipes

Protecting critical sections

Signal-handling routines normally execute with the signal that caused their invocation to be ``blocked'', but other signals may yet occur. Mechanisms are provided whereby ``critical-sections'' of code may protect themselves against the occurrence of specified signals.

To block a section of code against one or more signals, a call to sigprocmask may be used to add a set of signals to the existing mask and return the old mask:

   sigprocmask ( SIG_BLOCK ,
   	sigset_t *new_mask ,
   	sigset_t *old_mask )
The old mask can then be restored later with sigprocmask, as follows:
sigprocmask ( SIG_UNBLOCK ,
	sigset_t *new_mask ,
	sigset_t *old_mask )
The function sigprocmask can be used to read the current mask without changing it by specifying a null-pointer as its second argument.

It is possible to check conditions with some signals blocked and then to pause waiting for a signal and restoring the mask, by using:

sigsuspend (
	sigset_t *sig_mask )

Next topic: Signal stacks
Previous topic: system - signal programming example

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005