Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
.\"	$NetBSD: signal.7,v 1.25 2018/05/30 23:41:44 uwe Exp $
.\"
.\" Copyright (c) 1999, 2016 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 28, 2018
.Dt SIGNAL 7
.Os
.Sh NAME
.Nm signal
.Nd signal facilities
.Sh DESCRIPTION
A
.Nm
is a system-level notification delivered to a process.
Signals may be generated as the result of process activity, by certain
user inputs, by kernel facilities or subsystems, or sent
programmatically by other processes or by users.
There is a small fixed set of signals, each with a symbolic name and a
number.
For historical reasons many of the numbers are ``well-known values'',
which are in practice the same on all implementations and
realistically can never be changed.
(Nonetheless, compiled code should always use only the symbolic
names.)
Many/most signals also have specific semantics, both in how they can
be generated and in their effects.
Some are special cases in ways that have quite far-reaching
consequences.
.Pp
When a signal is
.Em posted
.Pq Dq sent
to a process, in general any of several things can happen.
If the process has elected to
.Em ignore
the signal, it is discarded and nothing happens.
(Some signals may not be ignored, however.)
If the process has elected to
.Em block
the signal temporarily, delivery is postponed until the process
later unblocks that signal.
Otherwise, the signal is
.Em delivered ,
meaning that whatever the process is doing is interrupted in order to
react to the signal.
(Note that processes that are waiting in the kernel must unwind what
they are doing for signals to be delivered.
This can sometimes be expensive.
See
.Xr sigaction 2
for further information.)
.Pp
If the process has elected to
.Em catch
the signal, which means that the process has installed a handler to
react to the signal in some process-specific way, the kernel arranges
for the process's handler logic to be invoked.
This is always done in a way that allows the process to resume if
desired.
(Note, however, that some signals may not be caught.)
Otherwise, the default action for the signal is taken.
For most signals the default action is a core dump.
See the table below.
Note that the term
.Em delivery
is also used for the specific process of arranging for a signal
handler to be invoked.
.Pp
In general, signals are delivered as soon as they are posted.
(Some delays may occur due to scheduling.)
However, in some cases a process that has been sleeping in the kernel
may need to do slow things as part of unwinding its state; this can
sometimes lead to human-perceptible delays.
.Pp
Also, some sleep states within the kernel are
.Em uninterruptible
meaning that signals posted will have no effect until the state
clears.
These states are supposed to be short-term only, but sometimes kernel
bugs make this not the case and one can end up with unkillable
processes.
Such processes appear in state "D" in
.Xr ps 1 .
In general the only way to get rid of them is to reboot.
(However, when the "wchan" reported is "tstile", it means the process
is waiting for some other process to release resources; sometimes if
one can find and kill that process the situation is recoverable.)
.Ss Signal list
The following signals are defined in
.Nx :
.Pp
.Bl -column ".Sy SIGVTALRM" 3n "Profiling timer expired blablabla" -compact
.\".It Sy "Symbol" Ta No Ta Sy "Descriptive name"
.It Dv SIGHUP Ta 1 Ta "Hangup"
.It Dv SIGINT Ta 2 Ta "Interrupt"
.It Dv SIGQUIT Ta 3 Ta "Quit"
.It Dv SIGILL Ta 4 Ta "Illegal instruction"
.It Dv SIGTRAP Ta 5 Ta "Trace/BPT trap"
.It Dv SIGABRT Ta 6 Ta "Abort trap"
.It Dv SIGEMT Ta 7 Ta "EMT trap"
.It Dv SIGFPE Ta 8 Ta "Floating point exception"
.It Dv SIGKILL Ta 9 Ta "Killed"
.It Dv SIGBUS Ta 10 Ta "Bus error"
.It Dv SIGSEGV Ta 11 Ta "Segmentation fault"
.It Dv SIGSYS Ta 12 Ta "Bad system call"
.It Dv SIGPIPE Ta 13 Ta "Broken pipe"
.It Dv SIGALRM Ta 14 Ta "Alarm clock"
.It Dv SIGTERM Ta 15 Ta "Terminated"
.It Dv SIGURG Ta 16 Ta "Urgent I/O condition"
.It Dv SIGSTOP Ta 17 Ta "Suspended (signal)"
.It Dv SIGTSTP Ta 18 Ta "Suspended"
.It Dv SIGCONT Ta 19 Ta "Continued"
.It Dv SIGCHLD Ta 20 Ta "Child exited, stopped or continued"
.It Dv SIGTTIN Ta 21 Ta "Stopped (tty input)"
.It Dv SIGTTOU Ta 22 Ta "Stopped (tty output)"
.It Dv SIGIO Ta 23 Ta "I/O possible"
.It Dv SIGXCPU Ta 24 Ta "CPU time limit exceeded"
.It Dv SIGXFSZ Ta 25 Ta "File size limit exceeded"
.It Dv SIGVTALRM Ta 26 Ta "Virtual timer expired"
.It Dv SIGPROF Ta 27 Ta "Profiling timer expired"
.It Dv SIGWINCH Ta 28 Ta "Window size changed"
.It Dv SIGINFO Ta 29 Ta "Information request"
.It Dv SIGUSR1 Ta 30 Ta "User defined signal 1"
.It Dv SIGUSR2 Ta 31 Ta "User defined signal 2"
.It Dv SIGPWR Ta 32 Ta "Power fail/restart"
.El
.Pp
These are numbered 1 to 32.
(There is no signal 0; 0 is a reserved value that can be used as a
no-op with some signal operations.)
.Pp
Detailed descriptions of these signals follow.
.Bl -tag -width "aaa"
.\" ************
.It Dv SIGHUP No (Hangup)
This signal is generated by the
.Xr tty 4
driver
to indicate a hangup condition on a process's controlling terminal:
the user has disconnected.
Accordingly, the default action is to terminate the process.
This signal is also used by many daemons,
such as
.Xr inetd 8 ,
as a cue to reload configuration.
The number for
.Dv SIGHUP
is\~1, which is quite well known.
.\" ************
.It Dv SIGINT No (Interrupt)
This signal is generated by the
.Xr tty 4
driver
when the user presses the interrupt character, normally control-C.
The default action is to terminate the process.
The number for
.Dv SIGINT
is\~2.
.\" ************
.It Dv SIGQUIT No (Quit)
This signal is generated by the
.Xr tty 4
driver
when the user presses the quit character, normally control-backspace.
The default action is to terminate the process and dump core.
The number for
.Dv SIGQUIT
is\~3.
.\" ************
.It Dv SIGILL No (Illegal instruction)
This signal is generated synchronously by the kernel when the process
executes an invalid instruction.
The default action is to terminate the process and dump core.
Note: the results of executing an illegal instruction when
.Dv SIGILL
is blocked or ignored are formally unspecified.
The number for
.Dv SIGILL
is\~4.
.\" ************
.It Dv SIGTRAP No (Trace/BPT trap)
This signal is used when a process is being traced
(see
.Xr ptrace 2 )
to indicate that the process has stopped at a breakpoint or after
single-stepping.
It is normally intercepted by the debugger and not exposed to the
debuggee.
The default action is to terminate the process and dump core.
The number for
.Dv SIGTRAP
is\~5.
.\" ************
.It Dv SIGABRT No (Abort trap)
This signal is generated when the
.Xr abort 3
standard library function is called.
The default action is to terminate the process and dump core.
The number for
.Dv SIGABRT
is\~6.
This number was also formerly used for
.Dv SIGIOT ,
which is no longer defined,
as it was specific to the PDP-11 instruction
.Dv iot .
.\" ************
.It Dv SIGEMT No (EMT trap)
In theory this signal is generated when an instruction needs to be
emulated.
.\"   XXX expand this -- I don't know, grep isn't helping much and
.\"   information seems pretty thin on the ground on the net.
The default action is to terminate the process and dump core.
The number for
.Dv SIGEMT
is\~7.
.\" ************
.It Dv SIGFPE No (Floating point exception)
This signal is generated when an invalid floating point operation is
detected by hardware or by a soft-float library.
The default action is to terminate the process and dump core.
The number for
.Dv SIGFPE
is\~8.
.\" ************
.It Dv SIGKILL No (Killed)
This signal cannot be caught or ignored.
The (unconditional) action is to terminate the process.
It is most often sent by system administrators, but is also generated
by the kernel in response to running completely out of memory and
swap space.
Note that because many processes need to perform cleanup before
exiting, it is usually best (as a user or administrator) to not deploy
.Dv SIGKILL
until a process has failed to respond to other signals.
The number for
.Dv SIGKILL
is\~9, which is extremely well known.
.\" ************
.It Dv SIGBUS No (Bus error)
This signal is generated synchronously by the kernel when the process
performs certain kinds of invalid memory accesses.
The most common cause of
.Dv SIGBUS
is an unaligned memory access; however, on some architectures it may
cover other memory conditions, such as attempts to access memory
belonging to the kernel.
The default action is to terminate the process and dump core.
Note: the results of performing such invalid accesses when
.Dv SIGBUS
is blocked or ignored are formally unspecified.
The number for
.Dv SIGBUS
is\~10.
.\" ************
.It Dv SIGSEGV No (Segmentation fault)
This signal is generated synchronously by the kernel when the process
attempts to access unmapped memory, or access memory in a manner that
the protection settings for that memory region do not permit.
On some architectures other assorted permission or protection errors
also yield
.Dv SIGSEGV .
On
.Nx ,
passing invalid pointers to system calls will yield failure with
.Er EFAULT
but not also
.Dv SIGSEGV .
The default action is to terminate the process and dump core.
Note: the results of an invalid memory access when
.Dv SIGSEGV
is blocked or ignored are formally unspecified.
The number for
.Dv SIGSEGV
is\~11, which is very well known.
.\" ************
.It Dv SIGSYS No (Bad system call)
This signal is generated by the kernel, in addition to failing with
.Er ENOSYS ,
when a system call is made using an invalid system call number.
.\" (This facility was intended to facilitate emulation of system calls.)
The default action is to terminate the process and dump core.
The number for
.Dv SIGSYS
is\~12.
.\" ************
.It Dv SIGPIPE No (Broken pipe)
This signal is generated by the kernel, in addition to failing with
.Er EPIPE ,
when a
.Xr write 2
call or similar is made on a pipe or socket that has been closed and
has no readers.
The default action is to terminate the process.
The number for
.Dv SIGPIPE
is\~13.
.\" ************
.It Dv SIGALRM No (Alarm clock)
This signal is generated by the kernel when a real-time timer expires.
See
.Xr alarm 3 ,
.Xr setitimer 2 ,
and
.Xr timer_settime 2 .
The default action is to terminate the process.
The number for
.Dv SIGALRM
is\~14.
.\" ************
.It Dv SIGTERM No (Terminated)
This signal is the default signal sent by
.Xr kill 1
and represents a user or administrator request that a program shut
down.
It is sent to all processes as part of the
.Xr shutdown 8
procedure.
The default action is to terminate the process.
The number for
.Dv SIGTERM
is\~15.
.\" ************
.It Dv SIGURG No (Urgent I/O condition)
This signal is generated when an ``urgent condition'' exists on a
socket.
In practice this means when
.Xr tcp 4
out-of-band data has arrived.
The default action is to do nothing.
The number for
.Dv SIGURG
is\~16.
.\" ************
.It Dv SIGSTOP No (Suspended (signal))
This signal cannot be caught or ignored.
The (unconditional) action is to stop the process.
Note that like with
.Dv SIGKILL
(and for similar reasons) it is best to not send this signal until a
process has failed to respond to
.Dv SIGTSTP .
It can also be used by processes to stop themselves after catching
.Dv SIGTSTP .
A process that is explicitly stopped will not run again until told to
with
.Dv SIGCONT .
The number for
.Dv SIGSTOP
is\~17.
.\" ************
.It Dv SIGTSTP No (Suspended)
This signal is generated by the
.Xr tty 4
driver
when the user presses the stop character, normally control-Z.
The default action is to stop the process.
The number for
.Dv SIGTSTP
is\~18.
.\" ************
.It Dv SIGCONT No (Continued)
This signal is generated by the job-control feature of shells to
manage processes.
It causes the target process to start executing again after previously
being stopped.
This happens as a magic extra effect
.Nm before
the signal is actually delivered.
The default action when the signal is delivered is to do nothing (else).
The number for
.Dv SIGCONT
is\~19.
.\" ************
.It Dv SIGCHLD No (Child exited, stopped or continued)
This signal is generated by the kernel when one of a process's
immediate children exits and can be waited for using one of the
.Xr wait 2
family of functions.
The default action is to do nothing.
As a special case hack, if
.Dv SIGCHLD
is ignored (not merely blocked) when a process is
.Em created ,
it is detached from its parent immediately so it need not be waited
for.
This behavior is a System V historic wart, implemented in
.Nx
only for compatibility.
It is not portable, not recommended, and should not be used by new
code.
.\" XXX should refer to something that can be used by new code...
The number for
.Dv SIGCHLD
is\~20.
This signal was spelled
.Dv SIGCLD
in old System V versions and today many systems provide both
spellings.
.\" ************
.It Dv SIGTTIN No (Stopped (tty input))
This signal is generated by the
.Xr tty 4
driver
when a process that is not in the foreground of its controlling
terminal attempts to read from this terminal.
The default action is to stop the process.
The number for
.Dv SIGTTIN
is\~21.
.\" ************
.It Dv SIGTTOU No (Stopped (tty output))
This signal is generated by the
.Xr tty 4
driver
when a process that is not in the foreground of its controlling
terminal attempts to write to this terminal, if the terminal is
configured accordingly, which is not the default.
(See
.Xr termios 4 . )
The default action is to stop the process.
The number for
.Dv SIGTTOU
is\~22.
.\" ************
.It Dv SIGIO No (I/O possible)
This signal is sent by the kernel when I/O becomes possible on a file
handle opened for asynchronous access with
.Dv O_ASYNC .
See
.Xr open 2
and
.Xr fcntl 2 .
The default action is to do nothing.
The number for
.Dv SIGIO
is\~23.
.\" ************
.It Dv SIGXCPU No (CPU time limit exceeded)
This signal is sent by the kernel when the amount of CPU time consumed
exceeds the configured limit.
See
.Xr setrlimit 2
and the
.Ic ulimit
and
.Ic rlimit
builtins of
.Xr sh 1
and
.Xr csh 1
respectively.
The default action is to terminate the process.
The number for
.Dv SIGXCPU
is\~24.
.\" ************
.It Dv SIGXFSZ No (File size limit exceeded)
This signal is sent by the kernel when a write causes the size of a
file to exceed the configured limit.
See
.Xr setrlimit 2
and the
.Ic ulimit
and
.Ic rlimit
builtins of
.Xr sh 1
and
.Xr csh 1
respectively.
The default action is to terminate the process.
The number for
.Dv SIGXFSZ
is\~25.
.\" ************
.It Dv SIGVTALRM No (Virtual timer expired)
This signal is generated by the kernel when a virtual-time (process
execution time) timer expires.
See
.Xr setitimer 2
and
.Xr timer_settime 2 .
The default action is to terminate the process.
The number for
.Dv SIGVTALRM
is\~26.
.\" ************
.It Dv SIGPROF No (Profiling timer expired)
This signal is generated by the kernel when a profiling timer
expires.
See
.Xr setitimer 2
and
.Xr timer_settime 2 .
The default action is to terminate the process.
The number for
.Dv SIGPROF
is\~27.
.\" ************
.It Dv SIGWINCH No (Window size changed)
This signal is generated by the
.Xr tty 4
driver
when the stored window size of the process's controlling terminal has
changed.
The default action is to do nothing.
The number for
.Dv SIGWINCH
is\~28.
.\" ************
.It Dv SIGINFO No (Information request)
This signal is generated by the
.Xr tty 4
driver
when the user presses the status request character, normally
control-T.
The default action is to do nothing.
The number for
.Dv SIGINFO
is\~29.
.\" ************
.It Dv SIGUSR1 No (User defined signal 1)
This signal is not generated by the system and is made available for
applications to use for their own purposes.
Many daemons use it for restart or reload requests of various types.
The default action is to terminate the process.
The number for
.Dv SIGUSR1
is\~30.
.\" ************
.It Dv SIGUSR2 No (User defined signal 2)
This signal is not generated by the system and is made available for
applications to use for their own purposes.
The default action is to terminate the process.
The number for
.Dv SIGUSR2
is\~31.
.\" ************
.It Dv SIGPWR No (Power fail/restart)
This signal is notionally sent by the kernel or by a privileged
monitor process when an external power failure is detected, and again
when power has been restored.
Currently
.Nx
does not in fact send
.Dv SIGPWR ,
although it is possible to prepare a custom configuration for
.Xr powerd 8
that does so.
The default action is to do nothing.
The number for
.Dv SIGPWR
is\~32.
.\" ************
.El
.Ss Shell Interface
Signals may be sent with the
.Xr kill 1
utility, either by number or the symbolic name without the ``SIG'' part.
This utility is built into many shells to allow addressing job control
jobs.
.Ss Program Interface
In C code signals may be sent using
.Xr raise 3 ,
.Xr kill 2 ,
.Xr pthread_kill 3 ,
and some other related functions.
.Pp
Signals may be caught or ignored using
.Xr sigaction 2
or the simpler
.Xr signal 3 ,
and blocked using
.Xr sigprocmask 2 .
.Sh STANDARDS
The
.Dv SIGTRAP ,
.Dv SIGEMT ,
.Dv SIGBUS ,
.Dv SIGSYS ,
.Dv SIGURG ,
.Dv SIGIO ,
.Dv SIGXCPU ,
.Dv SIGXFSZ ,
.Dv SIGVTALRM ,
.Dv SIGPROF ,
.Dv SIGWINCH ,
and
.Dv SIGINFO
signals are long-existing Berkeley extensions, available on most
.Bx Ns \-derived
systems.
The
.Dv SIGPWR
signal comes from System V.
.Pp
The remaining signals conform to
.St -p1003.1-90 .
.Sh HISTORY
.Dv SIGPWR
was introduced in
.Nx 1.4 .