Reference

siginfo(3)

signal generation information

NAME

siginfo – signal generation information

SYNOPSIS

#include <signal.h>

DESCRIPTION

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 siginfo_t, which includes the following information:

TypeMemberDescription
intsi_signo
intsi_errno
intsi_code
union sigvalsi_value
pid_tsi_pid
uid_tsi_uid
void*si_addr
intsi_status
longsi_band
intsi_trapno
intsi_timerid
intsi_overrun
intsi_mqd
intsi_syscall

The si_signo member contains the signal number.

The si_errno member contains an error number defined in the file ⟨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
SIGILLILL_ILLOPC
ILL_ILLOPN
ILL_ILLADR
ILL_ILLTRP
ILL_PRVOPC
ILL_PRVREG
ILL_COPROC
ILL_BADSTK
SIGFPEFPE_INTDIV
FPE_INTOVF
FPE_FLTDIV
FPE_FLTOVF
FPE_FLTUND
FPE_FLTRES
FPE_FLTINV
FPE_FLTSUB
SIGSEGVSEGV_MAPERR
SEGV_ACCERR
SIGBUSBUS_ADRALN
BUS_ADRERR
BUS_OBJERR
BUS_OOMERR
SIGTRAPTRAP_BRKPT
TRAP_TRACE
TRAP_DTRACE
TRAP_CAP
SIGCHLDCLD_EXITED
CLD_KILLED
CLD_DUMPED
CLD_TRAPPED
CLD_STOPPED
CLD_CONTINUED
SIGPOLLPOLL_IN
POLL_OUT
POLL_MSG
POLL_ERR
POLL_PRI
POLL_HUP
AnySI_NOINFO
SI_USER
SI_QUEUE
SI_TIMER
SI_ASYNCIO
SI_MESGQ
SI_KERNEL
SI_LWP

For synchronous signals, si_addr is generally set to the address of the faulting instruction. However, synchronous signals raised by a faulting memory access such as SIGSEGV and SIGBUS may report the address of the faulting memory access (if available) in si_addr instead. Additionally SIGTRAP raised by a hardware watchpoint exception may report the data address that triggered the watchpoint in si_addr.

Synchronous signals set si_trapno to a machine-dependent trap number.

In addition, the following signal-specific information is available:

SignalMemberValue
SIGCHLDsi_pid
si_status
si_uidreal user ID of the process that sent the signal
SIGPOLLsi_bandband event for

Finally, the following code-specific information is available:

CodeMemberValue
SI_USERsi_pid
si_uid
SI_QUEUEsi_value
si_pid
si_uid
SI_TIMERsi_value
si_timerid
si_overrun
si_errno
SI_ASYNCIOsi_value
SI_MESGQsi_value
si_mqd
SI_LWPsi_pid
si_uid

NOTES

Currently, the kernel never generates the SIGPOLL signal. SIGCHLD signal is queued when a process changed its status or exited. POSIX Realtime Extensions like aio, timer, and message queue also queue signals. Signals with code SI_USER, SI_KERNEL or SI_LWP are only queued if there are sufficient resources; otherwise, SI_NOINFO results. For some hardware architectures, the exact value of si_addr might not be available.

SEE ALSO

aio_read(2), kill(2), mq_notify(2), sigaction(2), sigqueue(2), sigwaitinfo(2), timer_create(2), timer_settime(2), waitpid(2), pthread_kill(3)

STANDARDS

The siginfo_t type conforms to IEEE Std 1003.1-2004 (“POSIX.1”).

HISTORY

Full support for POSIX signal information first appeared in FreeBSD 7.0. The codes SI_USER and SI_KERNEL can be generated as of FreeBSD 8.1. The code SI_LWP can be generated as of FreeBSD 9.0.

AUTHORS

This manual page was written by David Xu ⟨[email protected]⟩.

History