xref: /original-bsd/old/man/sigset.3 (revision 3b6250d9)
Copyright (c) 1980 Regents of the University of California.
All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.

@(#)sigset.3 4.1 (Berkeley) 05/15/85

SIGSET 3
C 4
NAME
sigset, signal, sighold, sigignore, sigrelse, sigpause - manage signals
SYNOPSIS
 #include <signal.h>  void action();  int sig; 

sigset(sig, action) signal(sig, action)

sighold(sig) sigignore(sig) sigrelse(sig)

sigpause(sig)

cc ... -ljobs
DESCRIPTION
This is a package of signal management functions to manage the signals as described in sigsys (2). These functions are available only in this version of UNIX, and should not be used when the mechanisms of signal (2) would suffice, as they would then impair portability. These functions are contained in the jobs library, obtained by specifying the loader option -ljobs.

Sigset is used to provide a default signal handler for signal sig. This function is remembered across subsequent calls to the other functions, and need not be specified again. After sigset instances of sig will cause an interrupt to be taken at func, with the signal then held so that recursive trapping due to the signal will not occur. During normal return from func, the routines arrange for the signal action to be restored so that subsequent signals will also trap to func. If a non-local exit is to be taken, then sigrelse must be called to un-hold the signal action, restoring the original catch. Func may also be specified as SIG_DFL, SIG_IGN or SIG_HOLD, as described in sigsys (2). The value specified on the previous call to sigset is returned; if sigset has never been called, then the default action inherited from the system is returned.

Signal is like sigset, but the signal will not be held when the action routine is called; rather it will have reverted to SIG_DFL. This is generally unsafe, but is included for backwards compatibility to the old signal mechanism. It should not be used.

Sighold and sigrelse may be used to block off sig in a piece of code where it cannot be tolerated. After sigrelse the catch initially set with sigset will be restored.

Sigignore can be used to temporarily set the action for sig to ignore the signal. If the signal had been held before the call to sigignore, any pending instance of the signal will be discarded.

Sigpause may be used by a routine which wishes to check for some condition produced at interrupt level by the sig signal, and then to pause waiting for the condition to arise with the catch of the signal enabled. In correct usage it must be preceded by an instance of sighold to block the signal. Sigpause is like pause in that it will return after any signal is processed. The usual thing to do then is to reenable the hold with sighold, check the condition again, and sigpause again if the condition has not arisen.

"SEE ALSO"
sigsys(2), signal(2), jobs(3), tty(4)
BUGS
Sighold and sigrelse do not nest; the first sigrelse restores the default catch.

These functions store information in data space. You thus must call sigsys (2) rather than any of sigset or signal after a vfork (2) in the child which is to then exec (2).