1.\" Copyright (c) 1980, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)sigvec.2 8.2 (Berkeley) 4/19/94 33.\" $FreeBSD$ 34.\" 35.Dd April 19, 1994 36.Dt SIGVEC 2 37.Os 38.Sh NAME 39.Nm sigvec 40.Nd software signal facilities 41.Sh LIBRARY 42.Lb libc 43.Sh SYNOPSIS 44.In signal.h 45.Bd -literal 46struct sigvec { 47 void (*sv_handler)(); 48 int sv_mask; 49 int sv_flags; 50}; 51.Ed 52.Ft int 53.Fn sigvec "int sig" "struct sigvec *vec" "struct sigvec *ovec" 54.Sh DESCRIPTION 55.Bf -symbolic 56This interface is made obsolete by 57.Xr sigaction 2 . 58.Ef 59.Pp 60The system defines a set of signals that may be delivered to a process. 61Signal delivery resembles the occurrence of a hardware interrupt: 62the signal is blocked from further occurrence, the current process 63context is saved, and a new one is built. A process may specify a 64.Em handler 65to which a signal is delivered, or specify that a signal is to be 66.Em blocked 67or 68.Em ignored . 69A process may also specify that a default action is to be taken 70by the system when a signal occurs. 71Normally, signal handlers execute on the current stack 72of the process. This may be changed, on a per-handler basis, 73so that signals are taken on a special 74.Em "signal stack" . 75.Pp 76All signals have the same 77.Em priority . 78Signal routines execute with the signal that caused their 79invocation 80.Em blocked , 81but other signals may yet occur. 82A global 83.Em "signal mask" 84defines the set of signals currently blocked from delivery 85to a process. The signal mask for a process is initialized 86from that of its parent (normally 0). It 87may be changed with a 88.Xr sigblock 2 89or 90.Xr sigsetmask 2 91call, or when a signal is delivered to the process. 92.Pp 93When a signal 94condition arises for a process, the signal is added to a set of 95signals pending for the process. If the signal is not currently 96.Em blocked 97by the process then it is delivered to the process. When a signal 98is delivered, the current state of the process is saved, 99a new signal mask is calculated (as described below), 100and the signal handler is invoked. The call to the handler 101is arranged so that if the signal handling routine returns 102normally the process will resume execution in the context 103from before the signal's delivery. 104If the process wishes to resume in a different context, then it 105must arrange to restore the previous context itself. 106.Pp 107When a signal is delivered to a process a new signal mask is 108installed for the duration of the process' signal handler 109(or until a 110.Xr sigblock 2 111or 112.Xr sigsetmask 2 113call is made). 114This mask is formed by taking the current signal mask, 115adding the signal to be delivered, and 116.Em or Ns 'ing 117in the signal mask associated with the handler to be invoked. 118.Pp 119.Fn Sigvec 120assigns a handler for a specific signal. If 121.Fa vec 122is non-zero, it 123specifies a handler routine and mask 124to be used when delivering the specified signal. 125Further, if the 126.Dv SV_ONSTACK 127bit is set in 128.Fa sv_flags , 129the system will deliver the signal to the process on a 130.Em "signal stack" , 131specified with 132.Xr sigaltstack 2 . 133If 134.Fa ovec 135is non-zero, the previous handling information for the signal 136is returned to the user. 137.Pp 138The following is a list of all signals 139with names as in the include file 140.Aq Pa signal.h : 141.Bl -column SIGVTALARMXX "create core imagexxx" 142.It Sy "NAME Default Action Description" 143.It Dv SIGHUP No " terminate process" " terminal line hangup" 144.It Dv SIGINT No " terminate process" " interrupt program" 145.It Dv SIGQUIT No " create core image" " quit program" 146.It Dv SIGILL No " create core image" " illegal instruction" 147.It Dv SIGTRAP No " create core image" " trace trap" 148.It Dv SIGABRT No " create core image" Ta Xr abort 3 149call (formerly 150.Dv SIGIOT ) 151.It Dv SIGEMT No " create core image" " emulate instruction executed" 152.It Dv SIGFPE No " create core image" " floating-point exception" 153.It Dv SIGKILL No " terminate process" " kill program" 154.It Dv SIGBUS No " create core image" " bus error" 155.It Dv SIGSEGV No " create core image" " segmentation violation" 156.It Dv SIGSYS No " create core image" " non-existent system call invoked" 157.It Dv SIGPIPE No " terminate process" " write on a pipe with no reader" 158.It Dv SIGALRM No " terminate process" " real-time timer expired" 159.It Dv SIGTERM No " terminate process" " software termination signal" 160.It Dv SIGURG No " discard signal" " urgent condition present on socket" 161.It Dv SIGSTOP No " stop process" " stop (cannot be caught or ignored)" 162.It Dv SIGTSTP No " stop process" " stop signal generated from keyboard" 163.It Dv SIGCONT No " discard signal" " continue after stop" 164.It Dv SIGCHLD No " discard signal" " child status has changed" 165.It Dv SIGTTIN No " stop process" " background read attempted from control terminal" 166.It Dv SIGTTOU No " stop process" " background write attempted to control terminal" 167.It Dv SIGIO No " discard signal" Tn " I/O" 168is possible on a descriptor (see 169.Xr fcntl 2 ) 170.It Dv SIGXCPU No " terminate process" " cpu time limit exceeded (see" 171.Xr setrlimit 2 ) 172.It Dv SIGXFSZ No " terminate process" " file size limit exceeded (see" 173.Xr setrlimit 2 ) 174.It Dv SIGVTALRM No " terminate process" " virtual time alarm (see" 175.Xr setitimer 2 ) 176.It Dv SIGPROF No " terminate process" " profiling timer alarm (see" 177.Xr setitimer 2 ) 178.It Dv SIGWINCH No " discard signal" " Window size change" 179.It Dv SIGINFO No " discard signal" " status request from keyboard" 180.It Dv SIGUSR1 No " terminate process" " User defined signal 1" 181.It Dv SIGUSR2 No " terminate process" " User defined signal 2" 182.El 183.Pp 184Once a signal handler is installed, it remains installed 185until another 186.Fn sigvec 187call is made, or an 188.Xr execve 2 189is performed. 190A signal-specific default action may be reset by 191setting 192.Fa sv_handler 193to 194.Dv SIG_DFL . 195The defaults are process termination, possibly with core dump; 196no action; stopping the process; or continuing the process. 197See the above signal list for each signal's default action. 198If 199.Fa sv_handler 200is 201.Dv SIG_IGN 202current and pending instances 203of the signal are ignored and discarded. 204.Pp 205If a signal is caught during the system calls listed below, 206the call is normally restarted. 207The call can be forced to terminate prematurely with an 208.Er EINTR 209error return by setting the 210.Dv SV_INTERRUPT 211bit in 212.Fa sv_flags . 213The affected system calls include 214.Xr read 2 , 215.Xr write 2 , 216.Xr sendto 2 , 217.Xr recvfrom 2 , 218.Xr sendmsg 2 219and 220.Xr recvmsg 2 221on a communications channel or a slow device (such as a terminal, 222but not a regular file) 223and during a 224.Xr wait 2 225or 226.Xr ioctl 2 . 227However, calls that have already committed are not restarted, 228but instead return a partial success (for example, a short read count). 229.Pp 230After a 231.Xr fork 2 232or 233.Xr vfork 2 234all signals, the signal mask, the signal stack, 235and the restart/interrupt flags are inherited by the child. 236.Pp 237.Xr Execve 2 238reinstates the default 239action for all signals which were caught and 240resets all signals to be caught on the user stack. 241Ignored signals remain ignored; 242the signal mask remains the same; 243signals that interrupt system calls continue to do so. 244.Sh NOTES 245The mask specified in 246.Fa vec 247is not allowed to block 248.Dv SIGKILL 249or 250.Dv SIGSTOP . 251This is done silently by the system. 252.Pp 253The 254.Dv SV_INTERRUPT 255flag is not available in 256.Bx 4.2 , 257hence it should not be used if backward compatibility is needed. 258.Sh RETURN VALUES 259.Rv -std sigvec 260.Sh ERRORS 261.Fn Sigvec 262will fail and no new signal handler will be installed if one 263of the following occurs: 264.Bl -tag -width Er 265.It Bq Er EFAULT 266Either 267.Fa vec 268or 269.Fa ovec 270points to memory that is not a valid part of the process 271address space. 272.It Bq Er EINVAL 273.Fa Sig 274is not a valid signal number. 275.It Bq Er EINVAL 276An attempt is made to ignore or supply a handler for 277.Dv SIGKILL 278or 279.Dv SIGSTOP . 280.El 281.Sh SEE ALSO 282.Xr kill 1 , 283.Xr kill 2 , 284.Xr ptrace 2 , 285.Xr sigaction 2 , 286.Xr sigaltstack 2 , 287.Xr sigblock 2 , 288.Xr sigpause 2 , 289.Xr sigprocmask 2 , 290.Xr sigsetmask 2 , 291.Xr sigsuspend 2 , 292.Xr setjmp 3 , 293.Xr siginterrupt 3 , 294.Xr signal 3 , 295.Xr sigsetops 3 , 296.Xr tty 4 297.Sh EXAMPLES 298On the 299.Tn VAX\-11 300The handler routine can be declared: 301.Bd -literal -offset indent 302void handler(sig, code, scp) 303int sig, code; 304struct sigcontext *scp; 305.Ed 306.Pp 307Here 308.Fa sig 309is the signal number, into which the hardware faults and traps are 310mapped as defined below. 311.Fa Code 312is a parameter that is either a constant 313as given below or, for compatibility mode faults, the code provided by 314the hardware (Compatibility mode faults are distinguished from the 315other 316.Dv SIGILL 317traps by having 318.Dv PSL_CM 319set in the psl). 320.Fa Scp 321is a pointer to the 322.Fa sigcontext 323structure (defined in 324.Aq Pa signal.h ) , 325used to restore the context from before the signal. 326.Sh BUGS 327This manual page is still confusing. 328