1 .\" $NetBSD: signal.3,v 1.24 2004/06/13 19:17:06 lha Exp $
3 .\" Copyright (c) 1980, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)signal.3 8.3 (Berkeley) 4/19/94
37 .Nd simplified software signal facilities
42 .\" The following is Quite Ugly, but syntactically correct. Don't try to
45 .Fn signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint"
50 is a simplified interface to the more general
54 Signals allow the manipulation of a process from outside its
55 domain as well as allowing the process to manipulate itself or
56 copies of itself (children).
57 There are two general types of signals:
58 those that cause termination of a process and those that do not.
59 Signals which cause termination of a program might result from
60 an irrecoverable error or might be the result of a user at a terminal
61 typing the `interrupt' character.
62 Signals are used when a process is stopped because it wishes to access
63 its control terminal while in the background (see
65 Signals are optionally generated
66 when a process resumes after being stopped,
67 when the status of child processes changes,
68 or when input is ready at the control terminal.
69 Most signals result in the termination of the process receiving them
71 is taken; some signals instead cause the process receiving them
72 to be stopped, or are simply discarded if the process has not
80 function allows for a signal to be caught, to be ignored, or to generate
84 for comprehensive list of supported signals.
88 procedure allows a user to choose the action upon receipt of a signal.
89 To set the default action of the signal to occur as listed above,
95 resets the default action.
100 This will cause subsequent instances of the signal to be ignored
101 and pending instances to be discarded.
105 further occurrences of the signal are
106 automatically blocked and
110 The handled signal is unblocked when the
112 the process continues from where it left off when the signal occurred.
114 Unlike previous signal facilities, the handler
115 func() remains installed after a signal has been delivered.
118 For some system calls, if a signal is caught while the call is
119 executing and the call is prematurely terminated,
120 the call is automatically restarted.
121 (The handler is installed using the
125 The affected system calls include
133 on a communications channel or a low speed device
138 However, calls that have already committed are not restarted,
139 but instead return a partial success (for example, a short read count).
141 When a process which has installed signal handlers forks,
142 the child process inherits the signals.
143 All caught signals may be reset to their default action by a call
147 ignored signals remain ignored.
149 Only functions that are async-signal-safe can safely be used in signal
154 The previous action is returned on a successful call.
157 is returned and the global variable
159 is set to indicate the error.
162 will fail and no action will take place if one of the following occur:
167 is not a valid signal number.
169 An attempt is made to ignore or supply a handler for