SIGSET(2) SysV SIGSET(2)
NAME
sigset, sighold, sigrelse, sigignore, sigpause - signal management
SYNOPSIS
#include <signal.h>
void (*sigset (sig, func))()
int sig;
void (*func)();
int sighold (sig)
int sig;
int sigrelse (sig)
int sig;
int sigignore (sig)
int sig;
int sigpause (sig)
int sig;
DESCRIPTION
These functions provide signal management for application processes.
sigset specifies the system signal action to be taken upon receipt of
signal sig. This action is either calling a process signal-catching
handler func or performing a system-defined action.
sig can be assigned any one of the following values except SIGKILL.
Machine or implementation dependent signals are not included (see NOTES
below). Each value of sig is a macro, defined in <signal.h>, that
expands to an integer constant expression.
SIGHUP hangup
SIGINT* interrupt (rubout)
SIGQUIT* quit (ASCII FS)
SIGILL* illegal instruction (not reset when caught)
SIGTRAP* trace trap (not reset when caught)
SIGIOT* IOT instruction
SIGABRT used by abort, replace SIGIOT in the future
SIGEMT* EMT instruction
SIGFPE* floating point exception
SIGKILL kill (cannot be caught or ignored)
SIGBUS* bus error
SIGSEGV* segmentation violation
SIGSYS* bad argument to system call
SIGPIPE write on a pipe with no one to read it
SIGALRM alarm clock
SIGTERM software termination signal from kill
SIGUSR1 user defined signal 1
SIGUSR2 user defined signal 2
SIGCLD death of a child (see "Warning")
SIGAPOLLO* Apollo-specific fault
SIGSTOP stop, cannot be caught, held, or ignored
SIGTSTP stop signal generated from keyboard
SIGCONT continue after stop
SIGCHLD child status has changed
SIGTTIN background read attempted from control terminal
SIGTTOU background write attempted to control terminal
SIGPOLL pollable event occured
SIGIO i/o is possible on a descriptor
SIGTINT input record is available at control terminal
SIGXCPU cpu time limit exceeded
SIGXFSZ file size limit exceeded
SIGVTALRM virtual time alarm
SIGPROF profiling timer alarm
SIGURG urgent condition present on socket
SIGWINCH window size changes
See below under SIG_DFL regarding asterisks (*) in the above list.
The following values for the system-defined actions of func are also
defined in <signal.h>. Each is a macro that expands to a constant
expression of type pointer to function returning void and has a unique
value that matches no declarable function.
SIG_DFL default system action
Upon receipt of the signal sig, the receiving process is to be
terminated with all of the consequences outlined in exit(2).
In addition, a process dump will be placed in the file
`node_data/system_logs/proc_dump if sig is one for which an an
asterisk appears in the above list. Use tb(1) to analyze a
process dump.
(Under some implementations, a "core image" will be made in
the current working directory of the receiving process if sig
is one for which an asterisk appears in the previous list
(excepting SIGINT and SIGAPOLLO) and the following conditions
are met:
⊕ The effective user ID and the real user ID of the receiving
process are equal.
⊕ An ordinary file named core exists and is writable or can
be created. If the file must be created, it will have the
following properties:
- A mode of 0666 modified by the file creation mask (see
umask(2))
- A file owner ID that is the same as the effective user
ID of the receiving process.
- A file group ID that is the same as the effective group
ID of the receiving process)
SIG_IGN ignore signal
Any pending signal sig is discarded and the system signal
action is set to ignore future occurrences of this signal
type.
SIG_HOLD hold signal
The signal sig is to be held upon receipt. Any pending signal
of this type remains held. Only one signal of each type is
held.
Otherwise, func must be a pointer to a function, the signal-catching
handler, that is to be called when signal sig occurs. In this case,
sigset specifies that the process will call this function upon receipt of
signal sig. Any pending signal of this type is released. This handler
address is retained across calls to the other signal management functions
listed here.
When a signal occurs, the signal number sig will be passed as the only
argument to the signal-catching handler. Before calling the signal-
catching handler, the system signal action will be set to SIG_HOLD .
During normal return from the signal-catching handler, the system signal
action is restored to func and any held signal of this type released. If
a non-local goto (longjmp) is taken, then sigrelse must be called to
restore the system signal action and release any held signal of this
type.
In general, upon return from the signal-catching handler, the receiving
process will resume execution at the point it was interrupted. However,
when a signal is caught during a read(2), a write(2), an open(2), or an
ioctl(2) system call during a sigpause system call, or during a wait(2)
system call that does not return immediately due to the existence of a
previously stopped or zombie process, the signal-catching handler will be
executed and then the interrupted system call may return a -1 to the
calling process with errno set to EINTR.
sighold and sigrelse are used to establish critical regions of code.
sighold is analogous to raising the priority level and deferring or
holding a signal until the priority is lowered by sigrelse. sigrelse
restores the system signal action to that specified previously by sigset.
sigignore sets the action for signal sig to SIG_IGN (see above).
sigpause suspends the calling process until it receives a signal, the
same as pause(2). However, if the signal sig had been received and held,
it is released and the system signal action taken. This system call is
useful for testing variables that are changed on the occurrence of a
signal. The correct usage is to use sighold to block the signal first,
then test the variables. If they have not changed, then call sigpause to
wait for the signal.
ERRORS
sigset will fail if one or more of the following are true:
[EINVAL] sig is an illegal signal number (including SIGKILL) or the
default handling of sig cannot be changed.
[EINTR] A signal was caught during the system call sigpause.
SEE ALSO
tb(1), kill(2), pause(2), signal(2), wait(2), setjmp(3C)
DIAGNOSTICS
Upon successful completion, sigset returns the previous value of the
system signal action for the specified signal sig. Otherwise, a value of
SIG_ERR is returned and errno is set to indicate the error. SIG_ERR is
defined in <signal.h>.
For the other functions, upon successful completion, a value of 0 is
returned. Otherwise, a value of -1 is returned and errno is set to
indicate the error.
NOTES
SIGPOLL is issued when a file descriptor corresponding to a STREAMS (see
intro(2)) file has a "selectable" event pending. A process must
specifically request that this signal be sent using the I_SETSIG ioctl(2)
call (see streamio(7)). Otherwise, the process will never receive
SIGPOLL.
For portability, applications should use only the symbolic names of
signals rather than their values and use only the set of signals defined
here. The action for the signal SIGKILL can not be changed from the
default system action.
The signal type SIGSEGV is reserved for the condition that occurs on an
invalid access to a data object. If an implementation can detect this
condition, this signal type should be used.
The other signal management functions, signal(2) and pause(2), should not
be used in conjunction with these routines for a particular signal type.
Domain systems send the signal SIGAPOLLO whenever a fault occurs that is
not otherwise mapped into a signal. Typical generators of SIGAPOLLO
include network failures, display-acquire timeouts, and disk full errors.
For SIGFPE, SIGILL, and SIGAPOLLO, you may use a routine like the one
below as the signal-catching func.
handler(sig, code)
int sig, code;
sig is the signal number into which the hardware faults and traps are
mapped as defined below. code is a 32-bit value. If the signal is
SIGAPOLLO, code is the Domain system status code describing the fault.
(To generate a list of Domain System status codes and brief explanations
of their meanings, run the command /systest/ssr_util/all_stcode.)
WARNINGS
One signal that behaves differently than the signals described above
exists in this release of the system: SIGCLD (death of a child (reset
when caught)). (SIGPWR (power fail), not defined in Domain/OS SysV, also
behaves differently in this release on those implementations where it is
defined.)
For this signal, func is assigned one of three values: SIG_DFL, SIG_IGN,
or a function address. The actions prescribed by these values are as
follows:
SIG_DFL ignore signal
The signal is to be ignored.
SIG_IGN ignore signal
The signal is to be ignored. Also, the calling
process' child processes will not create zombie
processes when they terminate (see exit(2)).
function address catch signal
The action to be taken is the same as that described
above for func equal to function address with one
exception: while the process is executing the
signal-catching function, any received SIGCLD signals
will be ignored. (This is the default action.)
SIGCLD affects two other system calls (wait(2) exit(2)) in the following
ways:
⊕ wait. If the func value of SIGCLD is set to SIG_IGN and a wait is
executed, the wait will block until all of the calling process' child
processes terminate; it will then return a value of -1 with errno set
to ECHILD.
⊕ exit. If in the exiting process' parent process the func value of
SIGCLD is set to SIG_IGN , the exiting process will not create a
zombie process.
When processing a pipeline, the shell makes the last process in the
pipeline the parent of the proceeding processes. A process that may be
piped into in this manner (and thus become the parent of other processes)
should take care not to set SIGCLD to be caught.