SIGVEC(2) BSD SIGVEC(2)
NAME
sigvec - software signal facilities
SYNOPSIS
#include <signal.h>
struct sigvec {
int (*sv_handler)();
int sv_mask;
int sv_flags;
};
sigvec(sig, vec, ovec)
int sig;
struct sigvec *vec, *ovec;
DESCRIPTION
The system defines a set of signals that can be delivered to a process.
Signal delivery resembles the occurrence of a hardware interrupt: the
signal is blocked, the current process context is saved, and a new one is
built. A signal can be blocked, ignored, or delivered to a handler, as
the process requires. A process can also specify a default action for
the system to take when a given signal occurs. Normally, signal handlers
execute on the current stack of the process. This can be changed, on a
per-handler basis, so that signals are taken on a special signal stack.
All signals have the same priority. While a signal routine executes, the
signal that triggered it is blocked, although other signals can occur. A
global signal mask defines the set of signals currently blocked from
delivery to a process. The signal mask for a process is initialized from
that of its parent (normally 0). It can be changed with a sigblock(2) or
sigsetmask(2) call, or when a signal is delivered to the process.
When a signal condition arises for a process, the signal is added to a
set of signals pending for the process. If the signal is not currently
blocked by the process, then it is delivered to the process. When a
signal is delivered, the current state of the process is saved, a new
signal mask is calculated (as described below), and the signal handler is
invoked. The call to the handler is arranged so that, if the signal
handling routine returns normally, the process will resume execution in
the context prior to the signal's delivery. If the process wishes to
resume in a different context, then it must arrange to restore the
previous context itself.
When a signal is delivered to a process, a new signal mask is installed
for the duration of the process' signal handler (or until a sigblock or
sigsetmask call is made). This mask is formed by taking the current
signal mask, adding the signal to be delivered, and ORing in the signal
mask associated with the handler to be invoked.
sigvec assigns a handler for a specific signal. If vec is nonzero, it
specifies a handler routine and mask to be used when delivering the
specified signal. Further, if SV_ONSTACK is set in sv_flags, the system
will deliver the signal to the process on a signal stack, specified with
sigstack(2). If ovec is nonzero, the previous handling information for
the signal is returned to the user.
The following is a list of all signals with names as in the include file
<signal.h>:
SIGHUP 1 hangup
SIGINT 2* interrupt
SIGQUIT 3* quit
SIGILL 4* illegal instruction (not reset when caught)
SIGTRAP 5* trace trap (not reset when caught)
SIGIOT 6* IOT instruction
SIGEMT 7* EMT instruction
SIGFPE 8* floating point exception
SIGKILL 9 kill (cannot be caught or ignored)
SIGBUS 10* bus error
SIGSEGV 11* segmentation violation
SIGSYS 12* bad argument to system call
SIGPIPE 13 write on a pipe with no one to read it
SIGALRM 14 alarm clock
SIGTERM 15 software termination signal from kill
SIGUSR1 16 user defined signal 1
SIGUSR2 17 user defined signal 2
SIGCLD 18 death of a child
SIGAPOLLO 19 Apollo-specific fault
SIGSTOP 20| sendable stop signal not from tty
SIGTSTP 21| stop signal from tty
SIGCONT 22@ continue a stopped process
SIGCHLD 23@ to parent on child stop or exit
SIGTTIN 24| to readers pgrp upon background tty read
SIGTTOU 25| like TTIN for output if (tp->t_local<OSTOP)
SIGIO 26@ input/output possible signal (see fcntl(2))
SIGTINT 26 input record is available at control terminal
SIGXCPU 27 exceeded CPU time limit (see getrlimit(2))
SIGXFSZ 28 exceeded file size limit (see getrlimit(2))
SIGVTALRM 29 virtual time alarm (see getitimer(2))
SIGPROF 30 profiling time alarm (see setitimer(2))
SIGURG 31@ urgent condition on IO channel
SIGWINCH 32@ window size changes
Legend:
* Results in a process dump, which you can examine using tb(1). (On
some systems, writes a core image if not caught or ignored.)
| Stops the process if sv_handler is set to SIG_DFL.
@ Signal is discarded if sv_handler is set to SIG_DFL.
Once a signal handler is installed, it remains installed until another
sigvec call is made, or an execve(2) is performed. The default action
for a signal can be reinstated by setting sv_handler to SIG_DFL; this
default is termination (with a core image for starred signals on some
systems) except for signals marked with @ or |. If sv_handler is
SIG_IGN, the signal is subsequently ignored and pending instances of the
signal are discarded.
If a caught signal occurs during certain system calls, the call is
normally restarted. The call can be forced to terminate prematurely with
an EINTR error return by setting the SV_INTERRUPT bit in sv_flags. The
affected system calls are read(2) or write(2) on a slow device (such as a
terminal (but not a file)) and during a wait(2).
After a fork(2) or vfork(2), the child inherits all signals, the signal
mask, the signal stack, and the restart/interrupt flags.
execve(2) resets all caught signals to default action and resets all
signals to be caught on the user stack. Ignored signals remain ignored,
the signal mask remains the same, and signals that interrupt system calls
continue to do so.
NOTES
The SV_INTERRUPT flag is not available in Domain/IX BSD4.2; hence, it
should not be used if backward compatibility is needed.
Domain/OS BSD sends the signal SIGAPOLLO whenever a fault occurs that is
not otherwise mapped into a signal. Typical generators of SIGAPOLLO
include network failures and disk full errors.
The system does not allow the mask specified in vec to block SIGKILL,
SIGSTOP, or SIGCONT.
When programming for Domain/OS BSD, use SIGCHLD (not SIGCLD) to be
signaled when a child changes state. SIGCHLD is generated for a process
whenever one of that process' immediate children changes state in such a
way that it can be waited for by wait(2): dies, becomes suspended due to
one of the suspend signals, or stops due to receiving a signal while
being traced (ptrace(2)).
Multiple occurrences of a signal received while the handler is blocked by
a wait(2) call are not stacked; only one instance of the signal is
delivered. To receive all occurrences, the handler must not be blocked
so it can loop and wait for children until no more are found. If a
signal handler must not block while waiting for the status of a child, it
should use wait3 with the appropriate option (WNOHANG or WUNTRACED).
(See wait(2)).
The handler routine can be declared as follows:
handler(sig, code, scp)
int sig, code;
struct sigcontext *scp;
Here 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.)
Otherwise, code is a value associated with one of the constants listed
below. scp is a pointer to the sigcontext structure (defined in
<signal.h>), used to restore the context from before the signal.
The following defines the mapping of Domain hardware traps to signals and
codes. All of these symbols are defined in <signal.h>:
Hardware condition Signal Code
Arithmetic traps:
Integer overflow SIGFPE FPE_INTOVF_TRAP
Integer division by zero SIGFPE FPE_INTDIV_TRAP
Floating overflow trap SIGFPE FPE_FLTOVF_TRAP
Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP
Floating underflow trap SIGFPE FPE_FLTUND_TRAP
Decimal overflow trap SIGFPE FPE_DECOVF_TRAP
Subscript-range SIGFPE FPE_SUBRNG_TRAP
Floating overflow fault SIGFPE FPE_FLTOVF_FAULT
Floating divide by zero fault SIGFPE FPE_FLTDIV_FAULT
Floating underflow fault SIGFPE FPE_FLTUND_FAULT
Floating operand error SIGFPE
Length access control SIGSEGV
Protection violation SIGBUS
Reserved instruction SIGILL ILL_RESAD_FAULT
Customer-reserved instr. SIGEMT
Reserved operand SIGILL ILL_PRIVIN_FAULT
Reserved addressing SIGILL ILL_RESOP_FAULT
Trace pending SIGTRAP
Bpt instruction SIGTRAP
Compatibility-mode SIGILL hardware supplied code
Chme SIGSEGV
Chms SIGSEGV
Chmu SIGSEGV
ERRORS
sigvec will fail and no new signal handler will be installed if one of
the following occurs:
[EINVAL] sig is not a valid signal number.
[EINVAL] An attempt is made to ignore or supply a handler for SIGKILL
or SIGSTOP.
[EINVAL] An attempt is made to ignore SIGCONT (by default SIGCONT is
ignored).
SEE ALSO
kill(1), ptrace(2), kill(2), sigblock(2), sigsetmask(2), sigpause(2),
sigstack(2), sigvec(2), setjmp(3), siginterrupt(3), tty(4)
DIAGNOSTICS
A successful call returns 0. A failed call returns -1 and sets errno as
indicated under "Errors."