A process may request signal information when it is catching a signal.
The information specifies why the system generated that signal.
To request signal information in a signal handler, the user can set
SA_SIGINFO
in
sa_flags
before
sigaction(2)
is called,
otherwise the user can use
sigwaitinfo(2)
and
sigtimedwait(2)
to get signal information.
In either case, the system returns the information in a structure of type
Vt siginfo_t ,
which includes the following information:
TypeMemberDescription
Vt int Ta si_signo Ta signal number
Vt int Ta si_errno Ta error number
Vt int Ta si_code Ta signal code
Vt union sigval Ta si_value Ta signal value
Vt pid_t Ta si_pid Ta sending process ID
Vt uid_t Ta si_uid Ta sending process's real user ID
Vt void Ta *si_addr Ta address of faulting instruction
Vt int Ta si_status Ta exit value or signal
Vt long Ta si_band Ta band event for
SIGPOLL
Vt int Ta si_trapno Ta machine trap code
Vt int Ta si_timerid Ta POSIX
timer ID
Vt int Ta si_overrun Ta POSIX
timer overrun count
Vt int Ta si_mqd Ta POSIX
message queue ID
The
si_signo
member contains the signal number.
The
si_errno
member contains an error number defined in the file
In errno.h .
The
si_code
member contains a code which describes the cause of the signal.
The macros specified in the
Code
column of the following table are defined
for use as values of
si_code
that are signal-specific or non-signal-specific reasons why the signal was
generated:
SignalCodeReason
SIGILL Ta ILL_ILLOPC Ta illegal opcode
Ta ILL_ILLOPN Ta illegal operand
Ta ILL_ILLADR Ta illegal addressing mode
Ta ILL_ILLTRP Ta illegal trap
Ta ILL_PRVOPC Ta illegal privileged opcode
Ta ILL_PRVREG Ta illegal privileged register
Ta ILL_COPROC Ta coprocessor error
Ta ILL_BADSTK Ta internal stack error
SIGFPE Ta FPE_INTDIV Ta integer divide by zero
Ta FPE_INTOVF Ta integer overflow
Ta FPE_FLTDIV Ta floating-point divide by zero
Ta FPE_FLTOVF Ta floating-point overflow
Ta FPE_FLTUND Ta floating-point underflow
Ta FPE_FLTRES Ta floating-point inexact result
Ta FPE_FLTINV Ta invalid floating-point operation
Ta FPE_FLTSUB Ta subscript out of range
SIGSEGV Ta SEGV_MAPERR Ta address not mapped to object
Ta SEGV_ACCERR Ta invalid permissions for mapped object
SIGBUS Ta BUS_ADRALN Ta invalid address alignment
Ta BUS_ADRERR Ta nonexistent physical address
Ta BUS_OBJERR Ta object-specific hardware error
SIGTRAP Ta TRAP_BRKPT Ta process breakpoint
Ta TRAP_TRACE Ta process trace trap
SIGCHLD Ta CLD_EXITED Ta child has exited
Ta CLD_KILLED Ta child has terminated abnormally and did not create a core file
Ta CLD_DUMPED Ta child has terminated abnormally and created a core file
Ta CLD_TRAPPED Ta traced child has trapped
Ta CLD_STOPPED Ta child has stopped
Ta CLD_CONTINUED Ta stopped child has continued
SIGPOLL Ta POLL_IN Ta data input available
Ta POLL_OUT Ta output buffers available
Ta POLL_MSG Ta input message available
Ta POLL_ERR Ta I/O error
Ta POLL_PRI Ta high priority input available
Ta POLL_HUP Ta device disconnected
Any Ta SI_NOINFO Ta Only the
si_signo
member is meaningful; the value of all other members is unspecified.
Ta SI_TIMER Ta signal generated by expiration of a timer set by
timer_settime2
Ta SI_ASYNCIO Ta signal generated by completion of an asynchronous I/O request
Ta SI_MESGQ Ta signal generated by arrival of a message on an empty message queue
In addition, the following signal-specific information is available:
SignalMemberValue
SIGILL Ta si_addr Ta address of faulting instruction
Ta si_trapno Ta machine dependent of trap code
SIGFPE Ta si_addr Ta address of faulting instruction
Ta si_trapno Ta machine dependent of trap code
SIGSEGV Ta si_addr Ta address of faulting memory reference
Ta si_trapno Ta machine dependent of trap code
SIGBUS Ta si_addr Ta address of faulting instruction
Ta si_trapno Ta machine dependent of trap code
SIGCHLD Ta Vt si_pid Ta child process ID
Ta si_status Ta exit value or signal; if
si_code
is equal to CLD_EXITED
then it is equal to the exit value of the child process, otherwise,
it is equal to a signal that caused the child process to change state.
Ta si_uid Ta real user ID of the process that sent the signal
SIGPOLL Ta si_band Ta band event for
POLL_IN , POLL_OUT
or
POLL_MSG
Finally, the following code-specific information is available:
Ta si_uid Ta real user ID of the process that sent the signal
SI_TIMER Ta si_value Ta the value passed to
timer_create2
system call
Ta si_timerid Ta the timer ID returned by
timer_create2
system call
Ta si_overrun Ta timer overrun count corresponding to the signal
Ta si_errno Ta If timer overrun will be
Br q Dv DELAYTIMER_MAX ,
an error code defined in
#include <errno.h>
is set
SI_ASYNCIO Ta si_value Ta the value passed to aio system calls
SI_MESGQ Ta si_value Ta the value passed to
mq_notify2
system call
Ta si_mqd Ta the ID of the message queue which generated the signal
NOTES
Currently, the kernel never generates the
SIGPOLL
signal.
Also, the
kill(2)
system call does not queue signals, so you will not get code
SI_USERSIGCHLD
signal is queued when a process changed its status or exited.
POSIX
Realtime Extensions like aio, timer, and message queue also queue
signals.
For some hardware architectures, the exact value of
si_addr
might not be available.