xref: /freebsd/share/man/man3/siginfo.3 (revision 02e9120893770924227138ba49df1edb3896112a)
1.\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
2.\" 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(s), this list of conditions and the following disclaimer as
9.\"    the first lines of this file unmodified other than the possible
10.\"    addition of one or more copyright notices.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice(s), this list of conditions and the following disclaimer in
13.\"    the documentation and/or other materials provided with the
14.\"    distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.Dd February 17, 2021
29.Dt SIGINFO 3
30.Os
31.Sh NAME
32.Nm siginfo
33.Nd "signal generation information"
34.Sh SYNOPSIS
35.In signal.h
36.Sh DESCRIPTION
37A process may request signal information when it is catching a signal.
38The information specifies why the system generated that signal.
39To request signal information in a signal handler, the user can set
40.Dv SA_SIGINFO
41in
42.Va sa_flags
43before
44.Xr sigaction 2
45is called,
46otherwise the user can use
47.Xr sigwaitinfo 2
48and
49.Xr sigtimedwait 2
50to get signal information.
51In either case, the system returns the information in a structure of type
52.Vt siginfo_t ,
53which includes the following information:
54.Bl -column ".Vt union signal" ".Va si_overrun"
55.It Sy Type Ta Sy Member Ta Sy Description
56.It Vt int Ta Va si_signo Ta
57signal number
58.It Vt int Ta Va si_errno Ta
59error number
60.It Vt int Ta Va si_code Ta
61signal code
62.It Vt union sigval Ta Va si_value Ta
63signal value
64.It Vt pid_t Ta Va si_pid Ta
65sending process ID
66.It Vt uid_t Ta Va si_uid Ta
67sending process's real user ID
68.It Vt void Ta Va *si_addr Ta
69virtual address
70.It Vt int Ta Va si_status Ta
71exit value or signal
72.It Vt long Ta Va si_band Ta
73band event for
74.Dv SIGPOLL
75.It Vt int Ta Va si_trapno Ta
76machine trap code
77.It Vt int Ta Va si_timerid Ta
78.Tn POSIX
79timer ID
80.It Vt int Ta Va si_overrun Ta
81.Tn POSIX
82timer overrun count
83.It Vt int Ta Va si_mqd Ta
84.Tn POSIX
85message queue ID
86.It Vt int Ta Va si_syscall Ta
87system-call number for system calls blocked by Capsicum
88.El
89.Pp
90The
91.Va si_signo
92member contains the signal number.
93.Pp
94The
95.Va si_errno
96member contains an error number defined in the file
97.In errno.h .
98.Pp
99The
100.Va si_code
101member contains a code which describes the cause of the signal.
102The macros specified in the
103.Sy Code
104column of the following table are defined
105for use as values of
106.Va si_code
107that are signal-specific or non-signal-specific reasons why the signal was
108generated:
109.Bl -column ".Dv SIGPOLL" ".Dv CLD_CONTINUED"
110.It Sy Signal Ta Sy Code Ta Sy Reason
111.It Dv SIGILL Ta Dv ILL_ILLOPC Ta
112illegal opcode
113.It Ta Dv ILL_ILLOPN Ta
114illegal operand
115.It Ta Dv ILL_ILLADR Ta
116illegal addressing mode
117.It Ta Dv ILL_ILLTRP Ta
118illegal trap
119.It Ta Dv ILL_PRVOPC Ta
120illegal privileged opcode
121.It Ta Dv ILL_PRVREG Ta
122illegal privileged register
123.It Ta Dv ILL_COPROC Ta
124coprocessor error
125.It Ta Dv ILL_BADSTK Ta
126internal stack error
127.It Dv SIGFPE Ta Dv FPE_INTDIV Ta
128integer divide by zero
129.It Ta Dv FPE_INTOVF Ta
130integer overflow
131.It Ta Dv FPE_FLTDIV Ta
132floating-point divide by zero
133.It Ta Dv FPE_FLTOVF Ta
134floating-point overflow
135.It Ta Dv FPE_FLTUND Ta
136floating-point underflow
137.It Ta Dv FPE_FLTRES Ta
138floating-point inexact result
139.It Ta Dv FPE_FLTINV Ta
140invalid floating-point operation
141.It Ta Dv FPE_FLTSUB Ta
142subscript out of range
143.It Dv SIGSEGV Ta Dv SEGV_MAPERR Ta
144address not mapped to object
145.It Ta Dv SEGV_ACCERR Ta
146invalid permissions for mapped object
147.It Dv SIGBUS Ta Dv BUS_ADRALN Ta
148invalid address alignment
149.It Ta Dv BUS_ADRERR Ta
150nonexistent physical address
151.It Ta Dv BUS_OBJERR Ta
152object-specific hardware error
153.It Ta Dv BUS_OOMERR Ta
154cannot alloc a page to map at fault
155.It Dv SIGTRAP Ta Dv TRAP_BRKPT Ta
156process breakpoint
157.It Ta Dv TRAP_TRACE Ta
158process trace trap
159.It Ta Dv TRAP_DTRACE Ta
160DTrace induced trap
161.It Ta Dv TRAP_CAP Ta
162capabilities protective trap
163.It Dv SIGCHLD Ta Dv CLD_EXITED Ta
164child has exited
165.It Ta Dv CLD_KILLED Ta
166child has terminated abnormally and did not create a core file
167.It Ta Dv CLD_DUMPED Ta
168child has terminated abnormally and created a core file
169.It Ta Dv CLD_TRAPPED Ta
170traced child has trapped
171.It Ta Dv CLD_STOPPED Ta
172child has stopped
173.It Ta Dv CLD_CONTINUED Ta
174stopped child has continued
175.It Dv SIGPOLL Ta Dv POLL_IN Ta
176data input available
177.It Ta Dv POLL_OUT Ta
178output buffers available
179.It Ta Dv POLL_MSG Ta
180input message available
181.It Ta Dv POLL_ERR Ta
182I/O error
183.It Ta Dv POLL_PRI Ta
184high priority input available
185.It Ta Dv POLL_HUP Ta
186device disconnected
187.It Any Ta Dv SI_NOINFO Ta
188Only the
189.Va si_signo
190member is meaningful; the value of all other members is unspecified.
191.It Ta Dv SI_USER Ta
192signal sent by
193.Xr kill 2
194.It Ta Dv SI_QUEUE Ta
195signal sent by
196.Xr sigqueue 2
197.It Ta Dv SI_TIMER Ta
198signal generated by expiration of a timer set by
199.Xr timer_settime 2
200.It Ta Dv SI_ASYNCIO Ta
201signal generated by completion of an asynchronous I/O request
202.It Ta Dv SI_MESGQ Ta
203signal generated by arrival of a message on an empty message queue
204.It Ta Dv SI_KERNEL Ta
205signal generated by miscellaneous parts of the kernel
206.It Ta Dv SI_LWP Ta
207signal sent by
208.Xr pthread_kill 3
209.El
210.Pp
211For synchronous signals,
212.Va si_addr
213is generally set to the address of the faulting instruction.
214However, synchronous signals raised by a faulting memory access such as
215.Dv SIGSEGV
216and
217.Dv SIGBUS
218may report the address of the faulting memory access (if available) in
219.Va si_addr
220instead.
221Additionally
222.Dv SIGTRAP
223raised by a hardware watchpoint exception may report the data address that
224triggered the watchpoint in
225.Va si_addr .
226.Pp
227Sychronous signals set
228.Va si_trapno
229to a machine-dependent trap number.
230.Pp
231In addition, the following signal-specific information is available:
232.Bl -column ".Dv SIGPOLL" ".Dv CLD_CONTINUED"
233.It Sy Signal Ta Sy Member Ta Sy Value
234.It Dv SIGCHLD Ta Va si_pid Ta
235child process ID
236.It Ta Va si_status Ta
237exit value or signal; if
238.Va si_code
239is equal to
240.Dv CLD_EXITED ,
241then it is equal to the exit value of the child process, otherwise,
242it is equal to a signal that caused the child process to change state.
243.It Ta Va si_uid Ta "real user ID of the process that sent the signal"
244.It Dv SIGPOLL Ta Va si_band Ta "band event for"
245.Dv POLL_IN , POLL_OUT ,
246or
247.Dv POLL_MSG
248.El
249.Pp
250Finally, the following code-specific information is available:
251.Bl -column ".Dv SI_ASYNCIO" ".Va si_overrun"
252.It Sy Code Ta Sy Member Ta Sy Value
253.It Dv SI_USER Ta Va si_pid Ta
254the process ID that sent the signal
255.It Ta Va si_uid Ta
256real user ID of the process that sent the signal
257.It Dv SI_QUEUE Ta Va si_value Ta
258the value passed to
259.Xr sigqueue 2
260system call
261.It Ta Va si_pid Ta
262the process ID that sent the signal
263.It Ta Va si_uid Ta
264real user ID of the process that sent the signal
265.It Dv SI_TIMER Ta Va si_value Ta
266the value passed to
267.Xr timer_create 2
268system call
269.It Ta Va si_timerid Ta
270the timer ID returned by
271.Xr timer_create 2
272system call
273.It Ta Va si_overrun Ta
274timer overrun count corresponding to the signal
275.It Ta Va si_errno Ta
276If timer overrun will be
277.Brq Dv DELAYTIMER_MAX ,
278an error code defined in
279.In errno.h
280is set
281.It Dv SI_ASYNCIO Ta Va si_value Ta
282the value passed to aio system calls
283.It Dv SI_MESGQ Ta Va si_value Ta
284the value passed to
285.Xr mq_notify 2
286system call
287.It Ta Va si_mqd Ta
288the ID of the message queue which generated the signal
289.It Dv SI_LWP Ta Va si_pid Ta
290the process ID that sent the signal
291.It Ta Va si_uid Ta
292real user ID of the process that sent the signal
293.El
294.Sh NOTES
295Currently, the kernel never generates the
296.Dv SIGPOLL
297signal.
298.Dv SIGCHLD
299signal is queued when a process changed its status or exited.
300.Tn POSIX
301Realtime Extensions like aio, timer, and message queue also queue
302signals.
303Signals with code
304.Dv SI_USER ,
305.Dv SI_KERNEL
306or
307.Dv SI_LWP
308are only queued if there are sufficient resources;
309otherwise,
310.Dv SI_NOINFO
311results.
312For some hardware architectures, the exact value of
313.Va si_addr
314might not be available.
315.Sh SEE ALSO
316.Xr aio_read 2 ,
317.Xr kill 2 ,
318.Xr mq_notify 2 ,
319.Xr sigaction 2 ,
320.Xr sigqueue 2 ,
321.Xr sigwaitinfo 2 ,
322.Xr timer_create 2 ,
323.Xr timer_settime 2 ,
324.Xr waitpid 2 ,
325.Xr pthread_kill 3
326.Sh STANDARDS
327The
328.Vt siginfo_t
329type conforms to
330.St -p1003.1-2004 .
331.Sh HISTORY
332Full support for
333.Tn POSIX
334signal information first appeared in
335.Fx 7.0 .
336The codes
337.Dv SI_USER
338and
339.Dv SI_KERNEL
340can be generated as of
341.Fx 8.1 .
342The code
343.Dv SI_LWP
344can be generated as of
345.Fx 9.0 .
346.Sh AUTHORS
347This manual page was written by
348.An David Xu Aq Mt davidxu@FreeBSD.org .
349