1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
|
<table class="head">
<tr>
<td class="head-ltitle">SIGNAL(9)</td>
<td class="head-vol">Kernel Developer's Manual</td>
<td class="head-rtitle">SIGNAL(9)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">signal</code>, <code class="Nm">siginit</code>,
<code class="Nm">sigactsinit</code>, <code class="Nm">sigactsunshare</code>,
<code class="Nm">sigactsfree</code>, <code class="Nm">execsigs</code>,
<code class="Nm">sigaction1</code>, <code class="Nm">sigprocmask1</code>,
<code class="Nm">sigpending1</code>, <code class="Nm">sigsuspend1</code>,
<code class="Nm">sigaltstack1</code>, <code class="Nm">pgsignal</code>,
<code class="Nm">kpgsignal</code>, <code class="Nm">psignal</code>,
<code class="Nm">kpsignal</code>, <code class="Nm">issignal</code>,
<code class="Nm">postsig</code>, <code class="Nm">killproc</code>,
<code class="Nm">sigexit</code>, <code class="Nm">trapsignal</code>,
<code class="Nm">sendsig</code>, <code class="Nm">sigcode</code>,
<code class="Nm">sigtramp</code> — <span class="Nd">software signal
facilities</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
<<a class="In">sys/signal.h</a>></code>
<br/>
<code class="In">#include <<a class="In">sys/signalvar.h</a>></code></p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">siginit</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *p</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">sigactsinit</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *pp</var>, <var class="Fa" style="white-space: nowrap;">int
share</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">sigactsunshare</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *p</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">sigactsfree</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *p</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">execsigs</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *p</var>);</p>
<p class="Pp"><var class="Ft">int</var>
<br/>
<code class="Fn">sigaction1</code>(<var class="Fa" style="white-space: nowrap;">struct
lwp *l</var>, <var class="Fa" style="white-space: nowrap;">int signum</var>,
<var class="Fa" style="white-space: nowrap;">const struct sigaction
*nsa</var>, <var class="Fa" style="white-space: nowrap;">struct sigaction
*osa</var>, <var class="Fa" style="white-space: nowrap;">void *tramp</var>,
<var class="Fa" style="white-space: nowrap;">int vers</var>);</p>
<p class="Pp"><var class="Ft">int</var>
<br/>
<code class="Fn">sigprocmask1</code>(<var class="Fa" style="white-space: nowrap;">struct
lwp *l</var>, <var class="Fa" style="white-space: nowrap;">int how</var>,
<var class="Fa" style="white-space: nowrap;">const sigset_t *nss</var>,
<var class="Fa" style="white-space: nowrap;">sigset_t *oss</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">sigpending1</code>(<var class="Fa" style="white-space: nowrap;">struct
lwp *l</var>, <var class="Fa" style="white-space: nowrap;">sigset_t
*ss</var>);</p>
<p class="Pp"><var class="Ft">int</var>
<br/>
<code class="Fn">sigsuspend1</code>(<var class="Fa" style="white-space: nowrap;">struct
lwp *l</var>, <var class="Fa" style="white-space: nowrap;">const sigset_t
*ss</var>);</p>
<p class="Pp"><var class="Ft">int</var>
<br/>
<code class="Fn">sigaltstack1</code>(<var class="Fa" style="white-space: nowrap;">struct
lwp *l</var>, <var class="Fa" style="white-space: nowrap;">const struct
sigaltstack *nss</var>, <var class="Fa" style="white-space: nowrap;">struct
sigaltstack *oss</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">pgsignal</code>(<var class="Fa" style="white-space: nowrap;">struct
pgrp *pgrp</var>, <var class="Fa" style="white-space: nowrap;">int
signum</var>, <var class="Fa" style="white-space: nowrap;">int
checkctty</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">kpgsignal</code>(<var class="Fa" style="white-space: nowrap;">struct
pgrp *pgrp</var>, <var class="Fa" style="white-space: nowrap;">ksiginfo_t
*ks</var>, <var class="Fa" style="white-space: nowrap;">void *data</var>,
<var class="Fa" style="white-space: nowrap;">int checkctty</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">psignal</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *p</var>, <var class="Fa" style="white-space: nowrap;">int
signum</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">kpsignal</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *p</var>, <var class="Fa" style="white-space: nowrap;">ksiginfo_t
*ks</var>, <var class="Fa" style="white-space: nowrap;">void
*data</var>);</p>
<p class="Pp"><var class="Ft">int</var>
<br/>
<code class="Fn">issignal</code>(<var class="Fa" style="white-space: nowrap;">struct
lwp *l</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">postsig</code>(<var class="Fa" style="white-space: nowrap;">int
signum</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">killproc</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *p</var>, <var class="Fa" style="white-space: nowrap;">const char
*why</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">sigexit</code>(<var class="Fa" style="white-space: nowrap;">struct
lwp *l</var>, <var class="Fa" style="white-space: nowrap;">int
signum</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">trapsignal</code>(<var class="Fa" style="white-space: nowrap;">struct
lwp *l</var>, <var class="Fa" style="white-space: nowrap;">const ksiginfo_t
*ks</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">sendsig</code>(<var class="Fa" style="white-space: nowrap;">const
ksiginfo_t *ks</var>, <var class="Fa" style="white-space: nowrap;">const
sigset_t *mask</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The system defines a set of signals that may be delivered to a
process. These functions implement the kernel portion of the signal
facility.</p>
<p class="Pp">Signal numbers used throughout the kernel signal facilities should
always be within the range of [1-NSIG].</p>
<p class="Pp">Most of the kernel's signal infrastructure is implemented in
machine-independent code. Machine-dependent code provides support for
invoking a process's signal handler, restoring context when the signal
handler returns, generating signals when hardware traps occur, triggering
the delivery of signals when a process is about to return from the kernel to
userspace.</p>
<p class="Pp">The signal state for a process is contained in
<var class="Fa">struct sigctx</var>. This includes the list of signals with
delivery pending, information about the signal handler stack, the signal
mask, and the address of the signal trampoline.</p>
<p class="Pp">The registered signal handlers for a process are recorded in
<var class="Fa">struct sigacts</var>. This structure may be shared by
multiple processes.</p>
<p class="Pp">The kernel's signal facilities are implemented by the following
functions:</p>
<dl class="Bl-tag">
<dt id="siginit"><a class="permalink" href="#siginit"><code class="Fn">siginit</code></a>(<var class="Fa">p</var>)</dt>
<dd>
<p class="Pp">This function initializes the signal state of
<var class="Va">proc0</var> to the system default. This signal state is
then inherited by <a class="Xr">init(8)</a> when it is started by the
kernel.</p>
</dd>
<dt id="sigactsinit"><a class="permalink" href="#sigactsinit"><code class="Fn">sigactsinit</code></a>(<var class="Fa">pp</var>,
<var class="Fa">share</var>)</dt>
<dd>
<p class="Pp">This function creates an initial <var class="Fa">struct
sigacts</var> for the process <var class="Fa">pp</var>. If the
<var class="Fa">share</var> argument is non-zero, then
<var class="Fa">pp</var> shares the <var class="Fa">struct sigacts</var>
by holding a reference. Otherwise, <var class="Fa">pp</var> receives a
new <var class="Fa">struct sigacts</var> which is copied from the
parent.</p>
</dd>
<dt id="sigactsunshare"><a class="permalink" href="#sigactsunshare"><code class="Fn">sigactsunshare</code></a>(<var class="Fa">p</var>)</dt>
<dd>
<p class="Pp">This function causes the process <var class="Fa">p</var> to no
longer share its <var class="Fa">struct sigacts</var> The current state
of the signal actions is maintained in the new copy.</p>
</dd>
<dt id="sigactsfree"><a class="permalink" href="#sigactsfree"><code class="Fn">sigactsfree</code></a>(<var class="Fa">p</var>)</dt>
<dd>
<p class="Pp">This function decrements the reference count on the
<var class="Fa">struct sigacts</var> of process <var class="Fa">p</var>.
If the reference count reaches zero, the <var class="Fa">struct
sigacts</var> is freed.</p>
</dd>
<dt id="execsigs"><a class="permalink" href="#execsigs"><code class="Fn">execsigs</code></a>(<var class="Fa">p</var>)</dt>
<dd>
<p class="Pp">This function is used to reset the signal state of the process
<var class="Fa">p</var> to the system defaults when the process execs a
new program image.</p>
</dd>
<dt id="sigaction1"><a class="permalink" href="#sigaction1"><code class="Fn">sigaction1</code></a>(<var class="Fa">l</var>,
<var class="Fa">signum</var>, <var class="Fa">nsa</var>,
<var class="Fa">osa</var>, <var class="Fa">tramp</var>,
<var class="Fa">vers</var>)</dt>
<dd>
<p class="Pp" id="sendsig">This function implements the
<a class="Xr">sigaction(2)</a> system call. The
<var class="Fa">tramp</var> and <var class="Fa">vers</var> arguments
provide support for userspace signal trampolines. Trampoline version 0
is reserved for the legacy kernel-provided signal trampoline;
<var class="Fa">tramp</var> must be <code class="Dv">NULL</code> in this
case. Otherwise, <var class="Fa">vers</var> specifies the ABI of the
trampoline specified by <var class="Fa">tramp</var>. The signal
trampoline ABI is machine-dependent, and must be coordinated with the
<a class="permalink" href="#sendsig"><code class="Fn">sendsig</code></a>()
function.</p>
</dd>
<dt id="sigprocmask1"><a class="permalink" href="#sigprocmask1"><code class="Fn">sigprocmask1</code></a>(<var class="Fa">l</var>,
<var class="Fa">how</var>, <var class="Fa">nss</var>,
<var class="Fa">oss</var>)</dt>
<dd>
<p class="Pp">This function implements the <a class="Xr">sigprocmask(2)</a>
system call.</p>
</dd>
<dt id="sigpending1"><a class="permalink" href="#sigpending1"><code class="Fn">sigpending1</code></a>(<var class="Fa">l</var>,
<var class="Fa">ss</var>)</dt>
<dd>
<p class="Pp">This function implements the <a class="Xr">sigpending(2)</a>
system call.</p>
</dd>
<dt id="sigsuspend1"><a class="permalink" href="#sigsuspend1"><code class="Fn">sigsuspend1</code></a>(<var class="Fa">l</var>,
<var class="Fa">ss</var>)</dt>
<dd>
<p class="Pp">This function implements the <a class="Xr">sigsuspend(2)</a>
system call.</p>
</dd>
<dt id="sigaltstack1"><a class="permalink" href="#sigaltstack1"><code class="Fn">sigaltstack1</code></a>(<var class="Fa">l</var>,
<var class="Fa">nss</var>, <var class="Fa">oss</var>)</dt>
<dd>
<p class="Pp">This function implements the <a class="Xr">sigaltstack(2)</a>
system call.</p>
</dd>
<dt id="pgsignal"><a class="permalink" href="#pgsignal"><code class="Fn">pgsignal</code></a>(<var class="Fa">pgrp</var>,
<var class="Fa">signum</var>, <var class="Fa">checkctty</var>)</dt>
<dd>
<p class="Pp" id="kpgsignal">This is a wrapper function for
<a class="permalink" href="#kpgsignal"><code class="Fn">kpgsignal</code></a>()
which is described below.</p>
</dd>
<dt><code class="Fn">kpgsignal</code>(<var class="Fa">pgrp</var>,
<var class="Fa">ks</var>, <var class="Fa">data</var>,
<var class="Fa">checkctty</var>)</dt>
<dd>
<p class="Pp" id="kpsignal">Schedule the signal
<var class="Fa">ks->ksi_signo</var> to be delivered to all members of
the process group <var class="Fa">pgrp</var>. If
<var class="Fa">checkctty</var> is non-zero, the signal is only sent to
processes which have a controlling terminal. The
<var class="Fa">data</var> argument and the complete signal scheduling
semantics are described in the
<a class="permalink" href="#kpsignal"><code class="Fn">kpsignal</code></a>()
function below.</p>
</dd>
<dt id="trapsignal"><a class="permalink" href="#trapsignal"><code class="Fn">trapsignal</code></a>(<var class="Fa">l</var>,
<var class="Fa">ks</var>)</dt>
<dd>
<p class="Pp">Sends the signal <var class="Fa">ks->ksi_signo</var> caused
by a hardware trap to the current process.</p>
</dd>
<dt id="psignal"><a class="permalink" href="#psignal"><code class="Fn">psignal</code></a>(<var class="Fa">p</var>,
<var class="Fa">signum</var>)</dt>
<dd>
<p class="Pp" id="kpsignal~2">This is a wrapper function for
<a class="permalink" href="#kpsignal~2"><code class="Fn">kpsignal</code></a>()
which is described below.</p>
</dd>
<dt><code class="Fn">kpsignal</code>(<var class="Fa">p</var>,
<var class="Fa">ks</var>, <var class="Fa">data</var>)</dt>
<dd>
<p class="Pp">Schedule the signal <var class="Fa">ks->ksi_signo</var> to
be delivered to the process <var class="Fa">p</var>. The
<var class="Fa">data</var> argument, if not
<code class="Dv">NULL</code>, points to the file descriptor data that
caused the signal to be generated in the <code class="Li">SIGIO</code>
case.</p>
<p class="Pp" id="issignal">With a few exceptions noted below, the target
process signal disposition is updated and is marked as runnable, so
further handling of the signal is done in the context of the target
process after a context switch; see
<a class="permalink" href="#issignal"><code class="Fn">issignal</code></a>()
below. Note that <code class="Fn">kpsignal</code>() does not by itself
cause a context switch to happen.</p>
<p class="Pp">The target process is not marked as runnable in the following
cases:</p>
<ul class="Bl-bullet Bd-indent">
<li>The target process is sleeping uninterruptibly. The signal will be
noticed when the process returns from the system call or trap.</li>
<li>The target process is currently ignoring the signal.</li>
<li>If a stop signal is sent to a sleeping process that takes the default
action (see <a class="Xr">sigaction(2)</a>), the process is stopped
without awakening it.</li>
<li>SIGCONT restarts a stopped process (or puts them back to sleep)
regardless of the signal action (e.g., blocked or ignored).</li>
</ul>
<p class="Pp" id="kpsignal~3">If the target process is being traced,
<a class="permalink" href="#kpsignal~3"><code class="Fn">kpsignal</code></a>()
behaves as if the target process were taking the default action for
<var class="Fa">signum</var>. This allows the tracing process to be
notified of the signal.</p>
</dd>
<dt><code class="Fn">issignal</code>(<var class="Fa">l</var>)</dt>
<dd>
<p class="Pp">This function determines which signal, if any, is to be posted
to the current process. A signal is to be posted if:</p>
<ul class="Bl-bullet Bd-indent">
<li>The signal has a handler provided by the program image.</li>
<li>The signal should cause the process to dump core and/or
terminate.</li>
<li>The signal should interrupt the current system call.</li>
</ul>
<p class="Pp" id="issignal~2">Signals which cause the process to be stopped
are handled within
<a class="permalink" href="#issignal~2"><code class="Fn">issignal</code></a>()
directly.</p>
<p class="Pp" id="issignal~3"><a class="permalink" href="#issignal~3"><code class="Fn">issignal</code></a>()
should be called by machine-dependent code when returning to userspace
from a system call or other trap or interrupt by using the following
code:</p>
<div class="Bd Pp Bd-indent Li">
<pre>while (signum = CURSIG(curproc))
postsig(signum);</pre>
</div>
</dd>
<dt id="postsig"><a class="permalink" href="#postsig"><code class="Fn">postsig</code></a>(<var class="Fa">signum</var>)</dt>
<dd>
<p class="Pp" id="postsig~2">The
<a class="permalink" href="#postsig~2"><code class="Fn">postsig</code></a>()
function is used to invoke the action for the signal
<var class="Fa">signum</var> in the current process. If the default
action of a signal is to terminate the process, and the signal does not
have a registered handler, the process exits using
<code class="Fn">sigexit</code>(), dumping a core image if
necessary.</p>
</dd>
<dt id="killproc"><a class="permalink" href="#killproc"><code class="Fn">killproc</code></a>(<var class="Fa">p</var>,
<var class="Fa">why</var>)</dt>
<dd>
<p class="Pp">This function sends a SIGKILL signal to the specified process.
The message provided by <var class="Fa">why</var> is sent to the system
log and is also displayed on the process's controlling terminal.</p>
</dd>
<dt id="sigexit"><a class="permalink" href="#sigexit"><code class="Fn">sigexit</code></a>(<var class="Fa">l</var>,
<var class="Fa">signum</var>)</dt>
<dd>
<p class="Pp">This function forces the current process to exit with the
signal <var class="Fa">signum</var>, generating a core file if
appropriate. No checks are made for masked or caught signals; the
process always exits.</p>
</dd>
<dt id="sendsig~2"><a class="permalink" href="#sendsig~2"><code class="Fn">sendsig</code></a>(<var class="Fa">ks</var>,
<var class="Fa">mask</var>)</dt>
<dd>
<p class="Pp" id="sendsig~3">This function is provided by machine-dependent
code, and is used to invoke a signal handler for the current process.
<a class="permalink" href="#sendsig~3"><code class="Fn">sendsig</code></a>()
must prepare the registers and stack of the current process to invoke
the signal handler stored in the process's <var class="Fa">struct
sigacts</var>. This may include switching to an alternate signal stack
specified by the process. The previous register, stack, and signal state
are stored in a <var class="Fa">ucontext_t</var>, which is then copied
out to the user's stack.</p>
<p class="Pp">The registers and stack must be set up to invoke the signal
handler as follows:</p>
<div class="Bd Pp Bd-indent Li">
<pre>(*handler)(int signum, siginfo_t *info, void *ctx)</pre>
</div>
<p class="Pp">where <var class="Fa">signum</var> is the signal number,
<var class="Fa">info</var> contains additional signal specific
information when <code class="Li">SA_SIGINFO</code> is specified when
setting up the signal handler. <var class="Fa">ctx</var> is the pointer
to <var class="Fa">ucontext_t</var> on the user's stack. The registers
and stack must also arrange for the signal handler to return to the
signal trampoline. The trampoline is then used to return to the code
which was executing when the signal was delivered using the
<a class="Xr">setcontext(2)</a> system call.</p>
<p class="Pp" id="sendsig~4">For performance reasons, it is recommended that
<a class="permalink" href="#sendsig~4"><code class="Fn">sendsig</code></a>()
arrange for the signal handler to be invoked directly on architectures
where it is convenient to do so. In this case, the trampoline is used
only for the signal return path. If it is not feasible to directly
invoke the signal handler, the trampoline is also used to invoke the
handler, performing any final set up that was not possible for
<code class="Fn">sendsig</code>() to perform.</p>
<p class="Pp" id="sendsig~5"><a class="permalink" href="#sendsig~5"><code class="Fn">sendsig</code></a>()
must invoke the signal trampoline with the correct ABI. The ABI of the
signal trampoline is specified on a per-signal basis in the
<a class="permalink" href="#sigacts"><code class="Fn" id="sigacts">sigacts</code></a>()
structure for the process. Trampoline version 0 is reserved for the
legacy kernel-provided, on-stack signal trampoline. All other trampoline
versions indicate a specific trampoline ABI. This ABI is coordinated
with machine-dependent code in the system C library.</p>
</dd>
</dl>
<section class="Ss">
<h2 class="Ss" id="SIGNAL_TRAMPOLINE"><a class="permalink" href="#SIGNAL_TRAMPOLINE">SIGNAL
TRAMPOLINE</a></h2>
<p class="Pp">The signal trampoline is a special piece of code which provides
support for invoking the signal handlers for a process. The trampoline is
used to return from the signal handler back to the code which was executing
when the signal was delivered, and is also used to invoke the handler itself
on architectures where it is not feasible to have the kernel invoke the
handler directly.</p>
<p class="Pp">In traditional <span class="Ux">UNIX</span> systems, the signal
trampoline, also referred to as the “sigcode”, is provided by
the kernel and copied to the top of the user's stack when a new process is
created or a new program image is exec'd. Starting in
<span class="Ux">NetBSD 2.0</span>, the signal trampoline is provided by the
system C library. This allows for more flexibility when the signal facility
is extended, makes dealing with signals easier in debuggers, such as
<a class="Xr">gdb(1)</a>, and may also enhance system security by allowing
the kernel to disallow execution of code on the stack.</p>
<p class="Pp">The signal trampoline is specified on a per-signal basis. The
correct trampoline is selected automatically by the C library when a signal
handler is registered by a process.</p>
<p class="Pp">Signal trampolines have a special naming convention which enables
debuggers to determine the characteristics of the signal handler and its
arguments. Trampoline functions are named like so:</p>
<div class="Bd Pp Bd-indent Li">
<pre>__sigtramp_<flavor>_<version></pre>
</div>
<p class="Pp">where:</p>
<dl class="Bl-tag">
<dt>⟨flavor⟩</dt>
<dd>The flavor of the signal handler. The following flavors are valid:
<dl class="Bl-tag">
<dt>sigcontext</dt>
<dd>Specifies a traditional BSD-style (deprecated) signal handler with the
following signature:
<div class="Bd Pp Li">
<pre>void (*handler)(int signum,
int code,
struct sigcontext *scp);</pre>
</div>
</dd>
<dt>siginfo</dt>
<dd>Specifies a POSIX-style signal handler with the following signature:
<div class="Bd Pp Li">
<pre>void (*handler)(int signum,
siginfo_t *si,
void *uc);</pre>
</div>
<p class="Pp">Note: sigcontext style signal handlers are deprecated, and
retained only for compatibility with older binaries.</p>
</dd>
</dl>
</dd>
<dt id="sendsig~6">⟨version⟩</dt>
<dd>Specifies the ABI version of the signal trampoline. The trampoline ABI is
coordinated with the machine-dependent kernel
<a class="permalink" href="#sendsig~6"><code class="Fn">sendsig</code></a>()
function. The trampoline version needs to be unique even across different
trampoline flavors, in order to simplify trampoline selection in the
kernel.</dd>
</dl>
<p class="Pp">The following is an example if a signal trampoline name which
indicates that the trampoline is used for traditional BSD-style signal
handlers and implements version 1 of the signal trampoline ABI:</p>
<div class="Bd Pp Bd-indent Li">
<pre>__sigtramp_sigcontext_1</pre>
</div>
<p class="Pp">The current signal trampoline is:</p>
<div class="Bd Pp Bd-indent Li">
<pre>__sigtramp_siginfo_2</pre>
</div>
</section>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<p class="Pp"><a class="Xr">sigaction(2)</a>, <a class="Xr">signal(7)</a>,
<a class="Xr">condvar(9)</a></p>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">April 29, 2010</td>
<td class="foot-os">NetBSD 10.1</td>
</tr>
</table>
|