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.El 87.Pp 88The 89.Va si_signo 90member contains the signal number. 91.Pp 92The 93.Va si_errno 94member contains an error number defined in the file 95.In errno.h . 96.Pp 97The 98.Va si_code 99member contains a code which describes the cause of the signal. 100The macros specified in the 101.Sy Code 102column of the following table are defined 103for use as values of 104.Va si_code 105that are signal-specific or non-signal-specific reasons why the signal was 106generated: 107.Bl -column ".Dv SIGPOLL" ".Dv CLD_CONTINUED" 108.It Sy Signal Ta Sy Code Ta Sy Reason 109.It Dv SIGILL Ta Dv ILL_ILLOPC Ta 110illegal opcode 111.It Ta Dv ILL_ILLOPN Ta 112illegal operand 113.It Ta Dv ILL_ILLADR Ta 114illegal addressing mode 115.It Ta Dv ILL_ILLTRP Ta 116illegal trap 117.It Ta Dv ILL_PRVOPC Ta 118illegal privileged opcode 119.It Ta Dv ILL_PRVREG Ta 120illegal privileged register 121.It Ta Dv ILL_COPROC Ta 122coprocessor error 123.It Ta Dv ILL_BADSTK Ta 124internal stack error 125.It Dv SIGFPE Ta Dv FPE_INTDIV Ta 126integer divide by zero 127.It Ta Dv FPE_INTOVF Ta 128integer overflow 129.It Ta Dv FPE_FLTDIV Ta 130floating-point divide by zero 131.It Ta Dv FPE_FLTOVF Ta 132floating-point overflow 133.It Ta Dv FPE_FLTUND Ta 134floating-point underflow 135.It Ta Dv FPE_FLTRES Ta 136floating-point inexact result 137.It Ta Dv FPE_FLTINV Ta 138invalid floating-point operation 139.It Ta Dv FPE_FLTSUB Ta 140subscript out of range 141.It Dv SIGSEGV Ta Dv SEGV_MAPERR Ta 142address not mapped to object 143.It Ta Dv SEGV_ACCERR Ta 144invalid permissions for mapped object 145.It Dv SIGBUS Ta Dv BUS_ADRALN Ta 146invalid address alignment 147.It Ta Dv BUS_ADRERR Ta 148nonexistent physical address 149.It Ta Dv BUS_OBJERR Ta 150object-specific hardware error 151.It Ta Dv BUS_OOMERR Ta 152cannot alloc a page to map at fault 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 209For synchronous signals, 210.Va si_addr 211is generally set to the address of the faulting instruction. 212However, synchronous signals raised by a faulting memory access such as 213.Dv SIGSEGV 214and 215.Dv SIGBUS 216may report the address of the faulting memory access (if available) in 217.Va si_addr 218instead. 219Additionally 220.Dv SIGTRAP 221raised by a hardware watchpoint exception may report the data address that 222triggered the watchpoint in 223.Va si_addr . 224.Pp 225Sychronous signals set 226.Va si_trapno 227to a machine-dependent trap number. 228.Pp 229In addition, the following signal-specific information is available: 230.Bl -column ".Dv SIGPOLL" ".Dv CLD_CONTINUED" 231.It Sy Signal Ta Sy Member Ta Sy Value 232.It Dv SIGCHLD Ta Va si_pid Ta 233child process ID 234.It Ta Va si_status Ta 235exit value or signal; if 236.Va si_code 237is equal to 238.Dv CLD_EXITED , 239then it is equal to the exit value of the child process, otherwise, 240it is equal to a signal that caused the child process to change state. 241.It Ta Va si_uid Ta "real user ID of the process that sent the signal" 242.It Dv SIGPOLL Ta Va si_band Ta "band event for" 243.Dv POLL_IN , POLL_OUT , 244or 245.Dv POLL_MSG 246.El 247.Pp 248Finally, the following code-specific information is available: 249.Bl -column ".Dv SI_ASYNCIO" ".Va si_overrun" 250.It Sy Code Ta Sy Member Ta Sy Value 251.It Dv SI_USER Ta Va si_pid Ta 252the process ID that sent the signal 253.It Ta Va si_uid Ta 254real user ID of the process that sent the signal 255.It Dv SI_QUEUE Ta Va si_value Ta 256the value passed to 257.Xr sigqueue 2 258system call 259.It Ta Va si_pid Ta 260the process ID that sent the signal 261.It Ta Va si_uid Ta 262real user ID of the process that sent the signal 263.It Dv SI_TIMER Ta Va si_value Ta 264the value passed to 265.Xr timer_create 2 266system call 267.It Ta Va si_timerid Ta 268the timer ID returned by 269.Xr timer_create 2 270system call 271.It Ta Va si_overrun Ta 272timer overrun count corresponding to the signal 273.It Ta Va si_errno Ta 274If timer overrun will be 275.Brq Dv DELAYTIMER_MAX , 276an error code defined in 277.In errno.h 278is set 279.It Dv SI_ASYNCIO Ta Va si_value Ta 280the value passed to aio system calls 281.It Dv SI_MESGQ Ta Va si_value Ta 282the value passed to 283.Xr mq_notify 2 284system call 285.It Ta Va si_mqd Ta 286the ID of the message queue which generated the signal 287.It Dv SI_LWP Ta Va si_pid Ta 288the process ID that sent the signal 289.It Ta Va si_uid Ta 290real user ID of the process that sent the signal 291.El 292.Sh NOTES 293Currently, the kernel never generates the 294.Dv SIGPOLL 295signal. 296.Dv SIGCHLD 297signal is queued when a process changed its status or exited. 298.Tn POSIX 299Realtime Extensions like aio, timer, and message queue also queue 300signals. 301Signals with code 302.Dv SI_USER , 303.Dv SI_KERNEL 304or 305.Dv SI_LWP 306are only queued if there are sufficient resources; 307otherwise, 308.Dv SI_NOINFO 309results. 310For some hardware architectures, the exact value of 311.Va si_addr 312might not be available. 313.Sh SEE ALSO 314.Xr aio_read 2 , 315.Xr kill 2 , 316.Xr mq_notify 2 , 317.Xr sigaction 2 , 318.Xr sigqueue 2 , 319.Xr sigwaitinfo 2 , 320.Xr timer_create 2 , 321.Xr timer_settime 2 , 322.Xr waitpid 2 , 323.Xr pthread_kill 3 324.Sh STANDARDS 325The 326.Vt siginfo_t 327type conforms to 328.St -p1003.1-2004 . 329.Sh HISTORY 330Full support for 331.Tn POSIX 332signal information first appeared in 333.Fx 7.0 . 334The codes 335.Dv SI_USER 336and 337.Dv SI_KERNEL 338can be generated as of 339.Fx 8.1 . 340The code 341.Dv SI_LWP 342can be generated as of 343.Fx 9.0 . 344.Sh AUTHORS 345This manual page was written by 346.An David Xu Aq Mt davidxu@FreeBSD.org . 347