SIGINFO(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 14.5, freebsd 15.1

πŸ’– NAME πŸ’–

<pink>siginfo</pink> β€” signal generation information. Bestie, this is SIGINFO(3) from the Library Functions Manual, and it's literally the whole rundown on why the system sent you a signal. ✨

🌸 SYNOPSIS 🌸

#include <signal.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: 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:

  • int β†’ si_signo β€” signal number
  • int β†’ si_errno β€” error number
  • int β†’ si_code β€” signal code
  • union sigval β†’ si_value β€” signal value
  • pid_t β†’ si_pid β€” sending process ID
  • uid_t β†’ si_uid β€” sending process's real user ID
  • void * β†’ si_addr β€” virtual address
  • int β†’ si_status β€” exit value or signal
  • long β†’ si_band β€” band event for SIGPOLL
  • int β†’ si_trapno β€” machine trap code
  • int β†’ si_timerid β€” POSIX timer ID
  • int β†’ si_overrun β€” POSIX timer overrun count
  • int β†’ si_mqd β€” POSIX message queue ID
  • int β†’ si_syscall β€” system-call number for system calls blocked by Capsicum

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:

  • SIGILL
    • ILL_ILLOPC β€” illegal opcode
    • ILL_ILLOPN β€” illegal operand
    • ILL_ILLADR β€” illegal addressing mode
    • ILL_ILLTRP β€” illegal trap
    • ILL_PRVOPC β€” illegal privileged opcode
    • ILL_PRVREG β€” illegal privileged register
    • ILL_COPROC β€” coprocessor error
    • ILL_BADSTK β€” internal stack error
  • SIGFPE
    • FPE_INTDIV β€” integer divide by zero
    • FPE_INTOVF β€” integer overflow
    • FPE_FLTDIV β€” floating-point divide by zero
    • FPE_FLTOVF β€” floating-point overflow
    • FPE_FLTUND β€” floating-point underflow
    • FPE_FLTRES β€” floating-point inexact result
    • FPE_FLTINV β€” invalid floating-point operation
    • FPE_FLTSUB β€” subscript out of range
  • SIGSEGV
    • SEGV_MAPERR β€” address not mapped to object
    • SEGV_ACCERR β€” invalid permissions for mapped object
  • SIGBUS
    • BUS_ADRALN β€” invalid address alignment
    • BUS_ADRERR β€” nonexistent physical address
    • BUS_OBJERR β€” object-specific hardware error
    • BUS_OOMERR β€” cannot alloc a page to map at fault
  • SIGTRAP
    • TRAP_BRKPT β€” process breakpoint
    • TRAP_TRACE β€” process trace trap
    • TRAP_DTRACE β€” DTrace induced trap
    • TRAP_CAP β€” capabilities protective trap
  • SIGCHLD
    • CLD_EXITED β€” child has exited
    • CLD_KILLED β€” child has terminated abnormally and did not create a core file
    • CLD_DUMPED β€” child has terminated abnormally and created a core file
    • CLD_TRAPPED β€” traced child has trapped
    • CLD_STOPPED β€” child has stopped
    • CLD_CONTINUED β€” stopped child has continued
  • SIGPOLL
    • POLL_IN β€” data input available
    • POLL_OUT β€” output buffers available
    • POLL_MSG β€” input message available
    • POLL_ERR β€” I/O error
    • POLL_PRI β€” high priority input available
    • POLL_HUP β€” device disconnected
  • Any
    • SI_NOINFO β€” Only the si_signo member is meaningful; the value of all other members is unspecified.
    • SI_USER β€” signal sent by kill(2)
    • SI_QUEUE β€” signal sent by sigqueue(2)
    • SI_TIMER β€” signal generated by expiration of a timer set by timer_settime(2)
    • SI_ASYNCIO β€” signal generated by completion of an asynchronous I/O request
    • SI_MESGQ β€” signal generated by arrival of a message on an empty message queue
    • SI_KERNEL β€” signal generated by miscellaneous parts of the kernel
    • SI_LWP β€” signal sent by pthread_kill(3)

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:

  • SIGCHLD
    • si_pid β€” child process ID
    • si_status β€” 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.
    • si_uid β€” real user ID of the process that sent the signal
  • SIGPOLL
    • si_band β€” band event for POLL_IN, POLL_OUT, or POLL_MSG

Finally, the following code-specific information is available:

  • SI_USER
    • si_pid β€” the process ID that sent the signal
    • si_uid β€” real user ID of the process that sent the signal
  • SI_QUEUE
    • si_value β€” the value passed to sigqueue(2) system call
    • si_pid β€” the process ID that sent the signal
    • si_uid β€” real user ID of the process that sent the signal
  • SI_TIMER
    • si_value β€” the value passed to timer_create(2) system call
    • si_timerid β€” the timer ID returned by timer_create(2) system call
    • si_overrun β€” timer overrun count corresponding to the signal
    • si_errno β€” If timer overrun will be {DELAYTIMER_MAX}, an error code defined in <errno.h> is set
  • SI_ASYNCIO
    • si_value β€” the value passed to aio system calls
  • SI_MESGQ
    • si_value β€” the value passed to mq_notify(2) system call
    • si_mqd β€” the ID of the message queue which generated the signal
  • SI_LWP
    • si_pid β€” the process ID that sent the signal
    • si_uid β€” real user ID of the process that sent the signal

🌈 NOTES 🌈

Okay, some tea: 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 🫢

πŸ‘‘ STANDARDS πŸ‘‘

The siginfo_t type conforms to IEEE Std 1003.1-2004 (β€œPOSIX.1”). Periodt. πŸ’…

🧚 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 <davidxu@FreeBSD.org>. Iconic. 🌟


πŸ’– And that's the tea: this page comes from the Debian source, dated February 17, 2021, and it's SIGINFO(3) β€” mwah, bestie! πŸ’…

πŸ“¦ where this page comes from