xref: /freebsd/share/man/man3/siginfo.3 (revision a25896ca1270e25b657ceaa8d47d5699515f5c25)
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 April 24, 2018
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
71address of faulting instruction
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.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 Dv SIGTRAP Ta Dv TRAP_BRKPT Ta
154process breakpoint
155.It Ta Dv TRAP_TRACE Ta
156process trace trap
157.It Ta Dv TRAP_DTRACE Ta
158DTrace induced trap
159.It Ta Dv TRAP_CAP Ta
160capabilities protective trap
161.It Dv SIGCHLD Ta Dv CLD_EXITED Ta
162child has exited
163.It Ta Dv CLD_KILLED Ta
164child has terminated abnormally and did not create a core file
165.It Ta Dv CLD_DUMPED Ta
166child has terminated abnormally and created a core file
167.It Ta Dv CLD_TRAPPED Ta
168traced child has trapped
169.It Ta Dv CLD_STOPPED Ta
170child has stopped
171.It Ta Dv CLD_CONTINUED Ta
172stopped child has continued
173.It Dv SIGPOLL Ta Dv POLL_IN Ta
174data input available
175.It Ta Dv POLL_OUT Ta
176output buffers available
177.It Ta Dv POLL_MSG Ta
178input message available
179.It Ta Dv POLL_ERR Ta
180I/O error
181.It Ta Dv POLL_PRI Ta
182high priority input available
183.It Ta Dv POLL_HUP Ta
184device disconnected
185.It Any Ta Dv SI_NOINFO Ta
186Only the
187.Va si_signo
188member is meaningful; the value of all other members is unspecified.
189.It Ta Dv SI_USER Ta
190signal sent by
191.Xr kill 2
192.It Ta Dv SI_QUEUE Ta
193signal sent by
194.Xr sigqueue 2
195.It Ta Dv SI_TIMER Ta
196signal generated by expiration of a timer set by
197.Xr timer_settime 2
198.It Ta Dv SI_ASYNCIO Ta
199signal generated by completion of an asynchronous I/O request
200.It Ta Dv SI_MESGQ Ta
201signal generated by arrival of a message on an empty message queue
202.It Ta Dv SI_KERNEL Ta
203signal generated by miscellaneous parts of the kernel
204.It Ta Dv SI_LWP Ta
205signal sent by
206.Xr pthread_kill 3
207.El
208.Pp
209In addition, the following signal-specific information is available:
210.Bl -column ".Dv SIGPOLL" ".Dv CLD_CONTINUED"
211.It Sy Signal Ta Sy Member Ta Sy Value
212.It Dv SIGILL Ta Va si_addr Ta
213address of faulting instruction
214.It Ta Va si_trapno Ta
215machine dependent of trap code
216.It Dv SIGFPE Ta Va si_addr Ta
217address of faulting instruction
218.It Ta Va si_trapno Ta
219machine dependent of trap code
220.It Dv SIGSEGV Ta Va si_addr Ta
221address of faulting memory reference
222.It Ta Va si_trapno Ta
223machine dependent of trap code
224.It Dv SIGBUS Ta Va si_addr Ta
225address of faulting instruction
226.It Ta Va si_trapno Ta
227machine dependent of trap code
228.It Dv SIGCHLD Ta Va si_pid Ta
229child process ID
230.It Ta Va si_status Ta
231exit value or signal; if
232.Va si_code
233is equal to
234.Dv CLD_EXITED ,
235then it is equal to the exit value of the child process, otherwise,
236it is equal to a signal that caused the child process to change state.
237.It Ta Va si_uid Ta "real user ID of the process that sent the signal"
238.It Dv SIGPOLL Ta Va si_band Ta "band event for"
239.Dv POLL_IN , POLL_OUT ,
240or
241.Dv POLL_MSG
242.El
243.Pp
244Finally, the following code-specific information is available:
245.Bl -column ".Dv SI_ASYNCIO" ".Va si_overrun"
246.It Sy Code Ta Sy Member Ta Sy Value
247.It Dv SI_USER Ta Va si_pid Ta
248the process ID that sent the signal
249.It Ta Va si_uid Ta
250real user ID of the process that sent the signal
251.It Dv SI_QUEUE Ta Va si_value Ta
252the value passed to
253.Xr sigqueue 2
254system call
255.It 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_TIMER Ta Va si_value Ta
260the value passed to
261.Xr timer_create 2
262system call
263.It Ta Va si_timerid Ta
264the timer ID returned by
265.Xr timer_create 2
266system call
267.It Ta Va si_overrun Ta
268timer overrun count corresponding to the signal
269.It Ta Va si_errno Ta
270If timer overrun will be
271.Brq Dv DELAYTIMER_MAX ,
272an error code defined in
273.In errno.h
274is set
275.It Dv SI_ASYNCIO Ta Va si_value Ta
276the value passed to aio system calls
277.It Dv SI_MESGQ Ta Va si_value Ta
278the value passed to
279.Xr mq_notify 2
280system call
281.It Ta Va si_mqd Ta
282the ID of the message queue which generated the signal
283.It Dv SI_LWP Ta Va si_pid Ta
284the process ID that sent the signal
285.It Ta Va si_uid Ta
286real user ID of the process that sent the signal
287.El
288.Sh NOTES
289Currently, the kernel never generates the
290.Dv SIGPOLL
291signal.
292.Dv SIGCHLD
293signal is queued when a process changed its status or exited.
294.Tn POSIX
295Realtime Extensions like aio, timer, and message queue also queue
296signals.
297Signals with code
298.Dv SI_USER ,
299.Dv SI_KERNEL
300or
301.Dv SI_LWP
302are only queued if there are sufficient resources;
303otherwise,
304.Dv SI_NOINFO
305results.
306For some hardware architectures, the exact value of
307.Va si_addr
308might not be available.
309.Sh SEE ALSO
310.Xr aio_read 2 ,
311.Xr kill 2 ,
312.Xr mq_notify 2 ,
313.Xr sigaction 2 ,
314.Xr sigqueue 2 ,
315.Xr sigwaitinfo 2 ,
316.Xr timer_create 2 ,
317.Xr timer_settime 2 ,
318.Xr waitpid 2 ,
319.Xr pthread_kill 3
320.Sh STANDARDS
321The
322.Vt siginfo_t
323type conforms to
324.St -p1003.1-2004 .
325.Sh HISTORY
326Full support for
327.Tn POSIX
328signal information first appeared in
329.Fx 7.0 .
330The codes
331.Dv SI_USER
332and
333.Dv SI_KERNEL
334can be generated as of
335.Fx 8.1 .
336The code
337.Dv SI_LWP
338can be generated as of
339.Fx 9.0 .
340.Sh AUTHORS
341This manual page was written by
342.An David Xu Aq Mt davidxu@FreeBSD.org .
343