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