SIGVEC(2) — UNIX Programmer’s Manual
NAME
sigvec − software signal facilities
SYNOPSIS
#include <signal.h>
struct sigvec {
int(∗sv_handler)();
intsv_mask;
intsv_onstack;
};
sigvec(sig, vec, ovec)
int sig;
struct sigvec ∗vec, ∗ovec;
DESCRIPTION
DYNIX defines a set of signals that may be delivered to a process. Signal delivery resembles the occurrence of a hardware interrupt—the signal is blocked from further occurrence, the current process context is saved, and a new process context is built. A process may specify a handler to which a signal is delivered, or specify that a signal is to be blocked or ignored. A process can tell the system to take a default action when a signal occurs. Normally, signal handlers execute on the current stack of the process. Processes can change this on a per-handler basis, so that signals are taken on a special signal stack, with a sigstack(2) system call.
Signals have the same priority. While a signal handler is executing, the signal that caused its invocation is blocked; however, other signals are not blocked. When a signal condition arises for a process, the signal is added to the set of signals pending for the process. If the process has not blocked the signal, the signal is delivered to the process. When a process receives a signal, the current state of the process is saved, a new signal mask is calculated, and sv_handler is invoked. The call to the signal handler is arranged so that if the signal handling routine returns normally, the process resumes execution in the context from before the signal’s delivery. If the process wishes to resume in a different context, it must arrange to restore the previous context itself.
Signal Mask
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, which is usually 0. The process can change signal mask with a sigblock(2) or sigsetmask(2) call, or DYNIX changes it when it delivers a signal to the process.
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 or’ing in the signal mask associated with the handler to be invoked.
Signal Handler
Sigvec assigns a handler for a specific signal. If vec is non-zero, it specifies a handler routine (sv_handler) and mask (sv_mask) to be used when delivering the specified signal. Further, if sv_onstack is 1, DYNIX delivers the signal to the process on a signal stack, as previously specified by sigstack(2). If ovec is non-zero, the previous handling information for the signal is returned to the user process.
The following is the list of signals as defined in <signal.h>:
SIGHUP1hangup
SIGINT2interrupt
SIGQUIT3∗quit
SIGILL4∗illegal instruction
SIGTRAP5∗trace trap
SIGIOT6∗IOT instruction
SIGEMT7∗EMT instruction
SIGFPE8∗floating point exception
SIGKILL9kill (cannot be caught, blocked, or ignored)
SIGBUS10∗bus error
SIGSEGV11∗segmentation violation
SIGSYS12∗bad argument to system call
SIGPIPE13write on a pipe with no one to read it
SIGALRM14alarm clock
SIGTERM15software termination signal
SIGURG16•urgent condition present on socket
SIGSTOP17†stop (cannot be caught, blocked, or ignored)
SIGTSTP18†stop signal generated from keyboard
SIGCONT19•continue after stop (cannot be blocked)
SIGCHLD20•child status has changed
SIGTTIN21†background read attempted from control terminal
SIGTTOU22†background write attempted to control terminal
SIGIO23•i/o is possible on a descriptor (see fcntl(2))
SIGXCPU24cpu time limit exceeded (see setrlimit(2))
SIGXFSZ25file size limit exceeded (see setrlimit(2))
SIGVTALRM26virtual time alarm (see setitimer(2))
SIGPROF27profiling timer alarm (see setitimer(2))
SIGWINCH28•used by PCI to signal a window size change
SIGUSR130user-defined signal 1
SIGUSR231user-defined signal 2
If the starred signals in the previous list are not caught or ignored, a core image is generated.
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 may be reinstated by setting sv_handler to SIG_DFL; this default is termination (with a core image for starred signals) except for signals marked with • or †. Signals marked with • are discarded if the action is SIG_DFL; signals marked with † cause the process to stop. 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, causing the call to terminate prematurely, the call is automatically restarted. In particular this can occur during a read 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, and the signal stack.
Execve(2) resets all caught signals to default action; ignored signals remain ignored; the signal mask remains the same; the signal stack state is reset.
NOTES
The mask specified in vec is not allowed to block SIGKILL, SIGSTOP, or SIGCONT. This is enforced silently by the system.
Signals do not stack. If two or more identical signals are sent to the process before the the process signal handler is called or the default action is taken, the second and subsequent consecutive identical signals are lost.
The handler routine can be declared:
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 parameter as given below. Scp is a pointer to the sigcontext structure defined in <signal.h>, which is used to restore the pre-signal context.
Balance Series
The following table shows the mapping of hardware traps to signals and codes as are defined in either <signal.h> or <machine/fpu.h>.
The following codes are associated with the SIGFPE floating point exception:
CodeHardware condition
FPE_INTDIV_TRAPInteger division by zero
FPE_FLTUND_TRAPFloating underflow trap
FPE_FLTOVF_TRAPFloating overflow trap
FPE_FLTDIV_TRAPFloating division by zero
FPE_FLTILL_TRAPFloating illegal instruction
FPE_FLTINV_TRAPFloating invalid operation
FPE_FLTIER_TRAPFloating inexact result
The following codes are associated with the SIGILL illegal instruction:
CodeHardware condition
ILL_PRIVIN_FAULTPrivileged instruction fault
ILL_RESOP_FAULTReserved operand fault
When a user process causes a segmentation violation (SIGVEC), the code parameter contains the address that caused the violation. Otherwise, code is set to zero for all other signals:
CodeSignalHardware condition
0SIGTRAPTrace pending
0SIGTRAPBpt instruction
0SIGEMTFlag trap
Unlike other processor architectures, such as the VAX, the stacked PC for a signal resulting from a hardware trap designates the instruction causing the trap, not the following instruction. Therefore, a hardware trap signal handler that returns without changing the context will attempt to execute the failed instruction repeatedly.
Symmetry Series
The following table shows the mapping of hardware traps to signals and codes as are defined in either <signal.h> or <machine/fpu.h>.
The following codes are associated with the SIGFPE floating point exception:
CodeHardware condition
FPE_FLTINV_TRAPFloating invalid operation
FPE_FLTDEN_TRAPFloating denormal trap
FPE_FLTDIV_TRAPFloating division by zero
FPE_FLTOVF_TRAPFloating overflow trap
FPE_FLTUND_TRAPFloating underflow trap
FPE_FLTPRE_TRAPFloating precision trap
FPE_FLTSTK_TRAPFloating stack overflow/underflow
FPE_INTDIV_TRAPInteger division by zero
FPE_INTOVF_TRAPInteger overflow (into)
FPE_NOFPA_AVAILNo Weitek 1167 FPA’s in the system
The following codes are associated with the SIGILL floating point exception:
CodeHardware condition
ILL_PRIVIN_FAULTPrivileged instruction fault
ILL_RESOP_FAULTReserved operand fault
In addition, the following signals are defined for the Weitek 1167 floating point hardware:
CodeHardware condition
FPA_PCR_AEAccumulated exceptions
FPA_PCR_AE_DEData chain exception
FPA_PCR_AE_UOEUnimplemented op-code exception
FPA_PCR_AE_PEPrecision exception
FPA_PCR_AE_UEUnderflow exception
FPA_PCR_AE_OEOverflow exception
FPA_PCR_AE_ZEZero divide exception
FPA_PCR_AE_EEEnabled exception (1 == interrupt)
FPA_PCR_AE_IEInvalid operation exception
RETURN VALUES
If the call succeeds, signal returns a 0. If the call fails, signal returns a −1 and sets errno to indicate the reason.
ERRORS
Sigvec fails and no new signal handler is installed if one of the following errors occurs:
[EFAULT] Either vec or ovec points to memory which is not a valid part of the process address space.
[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), sigpause(2), sigsetmask(2), sigstack(2), sigvec(2), setjmp(3), tty(4)
4BSD/DYNIX