Print this page
5281 incorrect realtime signal delivery
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man2/sigaction.2
+++ new/usr/src/man/man2/sigaction.2
1 1 '\" te
2 +.\" Copyright (c) 2014, Ryan Zezeski. All Rights Reserved.
2 3 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
3 4 .\" Copyright 1989 AT&T
4 5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 -.TH SIGACTION 2 "Mar 23, 2005"
8 +.TH SIGACTION 2 "Oct 22, 2014"
8 9 .SH NAME
9 10 sigaction \- detailed signal management
10 11 .SH SYNOPSIS
11 12 .LP
12 13 .nf
13 14 #include <signal.h>
14 15
15 16 \fBint\fR \fBsigaction\fR(\fBint\fR \fIsig\fR, \fBconst struct sigaction *restrict\fR \fIact\fR,
16 17 \fBstruct sigaction *restrict\fR \fIoact\fR);
17 18 .fi
18 19
19 20 .SH DESCRIPTION
20 -.sp
21 21 .LP
22 22 The \fBsigaction()\fR function allows the calling process to examine or specify
23 23 the action to be taken on delivery of a specific signal. See
24 24 \fBsignal.h\fR(3HEAD) for an explanation of general signal concepts.
25 25 .sp
26 26 .LP
27 27 The \fIsig\fR argument specifies the signal and can be assigned any of the
28 28 signals specified in \fBsignal.h\fR(3HEAD) except \fBSIGKILL\fR and
29 29 \fBSIGSTOP\fR.
30 30 .sp
31 31 .LP
32 32 If the argument \fIact\fR is not \fINULL\fR, it points to a structure
33 33 specifying the new action to be taken when delivering \fIsig\fR. If the
34 34 argument \fIoact\fR is not \fINULL\fR, it points to a structure where the
35 35 action previously associated with \fIsig\fR is to be stored on return from
36 36 \fBsigaction()\fR.
37 37 .sp
38 38 .LP
39 39 The \fBsigaction\fR structure includes the following members:
40 40 .sp
41 41 .in +2
42 42 .nf
43 43 void (*sa_handler)(\|);
44 44 void (*sa_sigaction)(int, siginfo_t *, void *);
45 45 sigset_t sa_mask;
46 46 int sa_flags;
47 47 .fi
48 48 .in -2
49 49
50 50 .sp
51 51 .LP
52 52 The storage occupied by \fBsa_handler\fR and \fBsa_sigaction\fR may overlap,
53 53 and a standard-conforming application (see \fBstandards\fR(5)) must not use
54 54 both simultaneously.
55 55 .sp
56 56 .LP
57 57 The \fBsa_handler\fR member identifies the action to be associated with the
58 58 specified signal, if the \fBSA_SIGINFO\fR flag (see below) is cleared in the
59 59 \fBsa_flags\fR field of the sigaction structure. It may take any of the values
60 60 specified in \fBsignal.h\fR(3HEAD) or that of a user specified signal handler.
61 61 If the \fBSA_SIGINFO\fR flag is set in the \fBsa_flags\fR field, the
62 62 \fBsa_sigaction\fR field specifies a signal-catching function.
63 63 .sp
64 64 .LP
65 65 The \fBsa_mask\fR member specifies a set of signals to be blocked while the
66 66 signal handler is active. On entry to the signal handler, that set of signals
67 67 is added to the set of signals already being blocked when the signal is
68 68 delivered. In addition, the signal that caused the handler to be executed will
69 69 also be blocked, unless the \fBSA_NODEFER\fR flag has been specified.
70 70 \fBSIGSTOP\fR and \fBSIGKILL\fR cannot be blocked (the system silently
71 71 enforces this restriction).
72 72 .sp
73 73 .LP
74 74 The \fBsa_flags\fR member specifies a set of flags used to modify the delivery
75 75 of the signal. It is formed by a logical \fBOR\fR of any of the following
76 76 values:
77 77 .sp
78 78 .ne 2
79 79 .na
80 80 \fB\fBSA_ONSTACK\fR\fR
81 81 .ad
82 82 .RS 16n
83 83 If set and the signal is caught, and if the thread that is chosen to processes
84 84 a delivered signal has an alternate signal stack declared with
85 85 \fBsigaltstack\fR(2), then it will process the signal on that stack. Otherwise,
86 86 the signal is delivered on the thread's normal stack.
87 87 .RE
88 88
89 89 .sp
90 90 .ne 2
91 91 .na
92 92 \fB\fBSA_RESETHAND\fR\fR
93 93 .ad
94 94 .RS 16n
95 95 If set and the signal is caught, the disposition of the signal is reset to
96 96 \fBSIG_DFL\fR and the signal will not be blocked on entry to the signal handler
↓ open down ↓ |
66 lines elided |
↑ open up ↑ |
97 97 (\fBSIGILL\fR, \fBSIGTRAP\fR, and \fBSIGPWR\fR cannot be automatically reset
98 98 when delivered; the system silently enforces this restriction).
99 99 .RE
100 100
101 101 .sp
102 102 .ne 2
103 103 .na
104 104 \fB\fBSA_NODEFER\fR\fR
105 105 .ad
106 106 .RS 16n
107 -If set and the signal is caught, the signal will not be automatically blocked
108 -by the kernel while it is being caught.
107 +If set and the signal is caught, the signal will not be automatically
108 +blocked by the kernel while it is being caught. Unless the signal is
109 +a realtime signal. Multiple instances of the same realtime signal
110 +must be delivered in FIFO order and thus are always deferred.
109 111 .RE
110 112
111 113 .sp
112 114 .ne 2
113 115 .na
114 116 \fB\fBSA_RESTART\fR\fR
115 117 .ad
116 118 .RS 16n
117 119 If set and the signal is caught, functions that are interrupted by the
118 120 execution of this signal's handler are transparently restarted by the system,
119 121 namely \fBfcntl\fR(2), \fBioctl\fR(2), \fBwait\fR(3C), \fBwaitid\fR(2), and the
120 122 following functions on slow devices like terminals: \fBgetmsg()\fR and
121 123 \fBgetpmsg()\fR (see \fBgetmsg\fR(2)); \fBputmsg()\fR and \fBputpmsg()\fR (see
122 124 \fBputmsg\fR(2)); \fBpread()\fR, \fBread()\fR, and \fBreadv()\fR (see
123 125 \fBread\fR(2)); \fBpwrite()\fR, \fBwrite()\fR, and \fBwritev()\fR (see
124 126 \fBwrite\fR(2)); \fBrecv()\fR, \fBrecvfrom()\fR, and \fBrecvmsg()\fR (see
125 127 \fBrecv\fR(3SOCKET)); and \fBsend()\fR, \fBsendto()\fR, and \fBsendmsg()\fR
126 128 (see \fBsend\fR(3SOCKET)). Otherwise, the function returns an \fBEINTR\fR
127 129 error.
128 130 .RE
129 131
130 132 .sp
131 133 .ne 2
132 134 .na
133 135 \fB\fBSA_SIGINFO\fR\fR
134 136 .ad
135 137 .RS 16n
136 138 If cleared and the signal is caught, \fIsig\fR is passed as the only argument
137 139 to the signal-catching function. If set and the signal is caught, two
138 140 additional arguments are passed to the signal-catching function. If the second
139 141 argument is not equal to \fINULL\fR, it points to a \fBsiginfo_t\fR structure
140 142 containing the reason why the signal was generated (see
141 143 \fBsiginfo.h\fR(3HEAD)); the third argument points to a \fBucontext_t\fR
142 144 structure containing the receiving process's context when the signal was
143 145 delivered (see \fBucontext.h\fR(3HEAD)).
144 146 .RE
145 147
146 148 .sp
147 149 .ne 2
148 150 .na
149 151 \fB\fBSA_NOCLDWAIT\fR\fR
150 152 .ad
151 153 .RS 16n
152 154 If set and \fIsig\fR equals \fBSIGCHLD\fR, the system will not create zombie
153 155 processes when children of the calling process exit. If the calling process
154 156 subsequently issues a \fBwait\fR(3C), it blocks until all of the calling
155 157 process's child processes terminate, and then returns \fB\(mi1\fR with
156 158 \fBerrno\fR set to \fBECHILD\fR.
157 159 .RE
158 160
159 161 .sp
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
160 162 .ne 2
161 163 .na
162 164 \fB\fBSA_NOCLDSTOP\fR\fR
163 165 .ad
164 166 .RS 16n
165 167 If set and \fIsig\fR equals \fBSIGCHLD\fR, \fBSIGCHLD\fR will not be sent to
166 168 the calling process when its child processes stop or continue.
167 169 .RE
168 170
169 171 .SH RETURN VALUES
170 -.sp
171 172 .LP
172 173 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
173 174 returned, \fBerrno\fR is set to indicate the error, and no new signal handler
174 175 is installed.
175 176 .SH ERRORS
176 -.sp
177 177 .LP
178 178 The \fBsigaction()\fR function will fail if:
179 179 .sp
180 180 .ne 2
181 181 .na
182 182 \fB\fBEINVAL\fR\fR
183 183 .ad
184 184 .RS 10n
185 185 The value of the \fIsig\fR argument is not a valid signal number or is equal to
186 186 \fBSIGKILL\fR or \fBSIGSTOP\fR. In addition, if in a multithreaded process, it
187 187 is equal to \fBSIGWAITING\fR, \fBSIGCANCEL\fR, or \fBSIGLWP\fR.
188 188 .RE
189 189
190 190 .SH ATTRIBUTES
191 -.sp
192 191 .LP
193 192 See \fBattributes\fR(5) for descriptions of the following attributes:
194 193 .sp
195 194
196 195 .sp
197 196 .TS
198 197 box;
199 198 c | c
200 199 l | l .
201 200 ATTRIBUTE TYPE ATTRIBUTE VALUE
202 201 _
203 202 Interface Stability Committed
204 203 _
205 204 MT-Level Async-Signal-Safe
206 205 _
207 206 Standard See \fBstandards\fR(5).
208 207 .TE
209 208
210 209 .SH SEE ALSO
211 -.sp
212 210 .LP
213 211 \fBkill\fR(1), \fBIntro\fR(2), \fBexit\fR(2), \fBfcntl\fR(2), \fBgetmsg\fR(2),
214 212 \fBioctl\fR(2), \fBkill\fR(2), \fBpause\fR(2), \fBputmsg\fR(2), \fBread\fR(2),
215 213 \fBsigaltstack\fR(2), \fBsigprocmask\fR(2), \fBsigsend\fR(2),
216 214 \fBsigsuspend\fR(2), \fBwaitid\fR(2), \fBwrite\fR(2), \fBrecv\fR(3SOCKET),
217 215 \fBsend\fR(3SOCKET), \fBsiginfo.h\fR(3HEAD), \fBsignal\fR(3C),
218 216 \fBsignal.h\fR(3HEAD), \fBsigsetops\fR(3C), \fBucontext.h\fR(3HEAD),
219 217 \fBwait\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
220 218 .SH NOTES
221 -.sp
222 219 .LP
223 220 The handler routine can be declared:
224 221 .sp
225 222 .in +2
226 223 .nf
227 224 void handler (int \fIsig\fR, siginfo_t *\fIsip\fR, ucontext_t *\fIucp\fR);
228 225 .fi
229 226 .in -2
230 227
231 228 .sp
232 229 .LP
233 230 The \fIsig\fR argument is the signal number. The \fIsip\fR argument is a
234 231 pointer (to space on the stack) to a \fBsiginfo_t\fR structure, which provides
235 232 additional detail about the delivery of the signal. The \fIucp\fR argument is a
236 233 pointer (again to space on the stack) to a \fBucontext_t\fR structure (defined
237 234 in <\fBsys/ucontext.h\fR>) which contains the context from before the signal.
238 235 It is not recommended that \fIucp\fR be used by the handler to restore the
239 236 context from before the signal delivery.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX