COHERENT manpages
This page displays the COHERENT manpage for sigset() [Specify action to take upon receipt of a given signal].
List of available manpages
Index
sigset() -- System Call (libc)
Specify action to take upon receipt of a given signal
#include <signal.h>
void (*sigset (sigtype, function))()
int sigtype;
void (*function)();
sigset() tells the signal handler what to do when the current process
receives signal sigtype.
sigtype identifies the signal being sought. For a list of recognized
signals, see the Lexicon entry for signal(). Note that the signal SIGKILL,
which kills a process, can be neither caught nor ignored.
function points to the function to be executed when sigtype is received.
This can be a function of your own creation; or you can use one of the
following macros, which expand into pointers to system-defined functions:
SIG_DFL
This is the default action. The process terminates just as if it
called the function exit(). In addition, the system writes a core file
in the current working directory if sigtype is any of the following:
SIGQUIT, SIGSYS, SIGTRAP, SIGSEGV, or SIGSYS. For more information on
core files, see the Lexicon entry core.
SIG_IGN
Ignore sigtype. The system discards all signals of this type.
SIG_HOLD
Hold sigtype. The signal is held until the process calls sigrelse() to
release it. Once the signal is released, it is processed as defined
by sigset(). Only one ``copy'' of sigtype can be held at any given
time.
If all goes well, sigset() returns a pointer to the routine that had
previously been in place to process sigtype. If something goes wrong (e.g.,
sigtype is not defined in signal.h), sigset() returns SIG_ERR and sets
errno to an appropriate value.
sigset() Versus signal()
The COHERENT system also include the system call signal(), which also
handles signals. signal() predates sigset() and its related functions
sighold(), sigignore(), sigpause(), and sigrelse(). You should never
combine signal() with the sigset() family of functions: use one or the
other, but not both.
The sigset() functions differ from signal() in the way they handle signals
while a signal is being processed: signal() automatically invokes SIG_DFL
for sigtype while its function is executing; whereas sigset() and its
related functions invoke SIG_HOLD.
Thus, with signal(), sending signal sigtype to a program while that
signal's function is already executing will trigger the default action,
which in most instances is to exit from the program. The signal-handling
function itself can call signal() to reset the signal-handler to point to
itself or another function; however, there remains a brief interval of
vulnerability between the time the signal-processing function is called and
the time it calls signal() to program the signal handler. With sigset(),
however, if another sigtype is received while its function processing, the
signal handler holds it, and releases it automatically after function
returns.
sigset() also differs from signal() in the way in which the signal-handler
is reset once sigtype has been processed. With signal(), function is
automatically reset to SIG_DFL just before a signal of type sigtype is
processed. If you wish sigtype always to be processed by function, you
must explicitly re-invoke signal() for sigtype within function. However,
the sigset() family of routines always process sigtype by the routine to
which function points until you explicitly change it.
See Also
libc,
sighold(),
sigignore(),
signal(),
sigpause(),
sigrelse()
Notes
Functions called from within a signal handler should be re-entrant; this
includes the standard I/O library. Thus, in general, it is not a good idea
to call printf() from inside a signal handler. The risk is that a signal
will arrive while the main program is updating a static structure, or
calling malloc(); then the signal handler will run when something is not in
a consistent state, with unpredictable results.









