SIGINFO(2)

๐Ÿ“ฆ version 11.0, in nixpkgs unstable

๐Ÿ’– SIGINFO(2) ๐Ÿ’–

okay bestie, this is the System Calls Manual page for siginfo โ€” literally signal information. no cap, itโ€™s the struct that spills the tea about a signal that got delivered to your process ๐Ÿซถ

๐ŸŒธ NAME ๐ŸŒธ

siginfo โ€” signal information

โœจ SYNOPSIS โœจ

#include <signal.h>

๐Ÿ’… DESCRIPTION ๐Ÿ’…

<hotpink>siginfo</hotpink> is a structure type, and it contains info about a signal delivered to a process. iconic little data container, honestly ๐Ÿ’–

<purple>siginfo</purple> includes these members:

int si_signo;
int si_errno;
int si_code;
  • si_signo โ€” contains the signal number generated by the system โญ
  • si_errno โ€” if itโ€™s non-zero, then it contains a system specific error number associated with this signal. that number is defined in errno(2).
  • si_code โ€” the main-character field that tells you where the signal came from ๐Ÿ‘‘

if si_code is less than or equal to zero, the signal was generated by a user process or a user requested service. itโ€™s giving โ€œuser-side origin storyโ€ โœจ

๐Ÿซถ SI_USER

the signal was generated via kill(2). the siginfo structure contains these additional members:

pid_t si_pid;
uid_t si_uid;

the si_pid field contains the pid of the sending process, and the si_uid field contains the user id of the sending process ๐ŸŽ€

๐Ÿ’Œ SI_QUEUE

the signal was generated via sigqueue(2). the siginfo structure contains these additional members:

pid_t si_pid;
uid_t si_uid;
sigval_t si_value;

the si_pid field contains the pid of the sending process, and the si_uid field contains the user id of the sending process. finally, the si_value field contains the value sent via sigqueue(2) ๐Ÿ’…

โฐ SI_TIMER

the signal was generated because a timer set by timer_settime(2) has expired. the siginfo structure contains this additional member:

sigval_t si_value;

the si_value field contains the value set via timer_create(2) โฑ๏ธ

๐Ÿฆ‹ SI_ASYNCIO

the signal was generated by completion of an asynchronous I/O operation. the siginfo structure contains these additional members:

int si_fd;
long si_band;

the si_fd argument contains the file descriptor number on which the operation was completed, and the si_band field contains the side and priority of the operation.

if the operation was a normal read, si_band will contain POLLIN | POLLRDNORM; on an out-of-band read it will contain POLLPRI | POLLRDBAND; on a normal write it will contain POLLOUT | POLLWRNORM; on an out-of-band write it will contain POLLPRI | POLLWRBAND. slay, extremely specific ๐Ÿ’€โœจ

๐Ÿ“ฌ SI_MESGQ

the signal was generated because of the arrival of a message on an empty message queue. see mq_notify(3).

๐ŸŒˆ SI_LWP

the signal was generated via _lwp_kill(2). the siginfo structure contains these additional members:

pid_t si_pid;
uid_t si_uid;

the si_pid field contains the pid of the sending process, and the si_uid field contains the user id of the sending process ๐Ÿซถ

๐Ÿ’€ SI_NOINFO

the signal was generated without specific info available. mysterious. elusive. no notes.


if si_code is positive, then it contains a signal specific reason why the signal was generated ๐Ÿ‘‘

๐ŸŒŸ SIGILL

  • ILL_BADSTK โ€” Internal stack error
  • ILL_COPROC โ€” Coprocessor error
  • ILL_ILLADR โ€” Illegal addressing mode
  • ILL_ILLOPC โ€” Illegal opcode
  • ILL_ILLOPN โ€” Illegal operand
  • ILL_ILLTRP โ€” Illegal trap
  • ILL_PRVOPC โ€” Privileged opcode
  • ILL_PRVREG โ€” Privileged register

๐Ÿงฎ SIGFPE

  • FPE_FLTDIV โ€” Floating-point divide by zero
  • FPE_FLTINV โ€” Invalid floating-point operation
  • FPE_FLTOVF โ€” Floating-point overflow
  • FPE_FLTRES โ€” Floating-point inexact result
  • FPE_FLTUND โ€” Floating-point underflow
  • FPE_FLTSUB โ€” Subscript out of range
  • FPE_INTDIV โ€” Integer divide by zero
  • FPE_INTOVF โ€” Integer overflow

๐Ÿงจ SIGSEGV

  • SEGV_ACCERR โ€” Invalid permissions for mapped object
  • SEGV_MAPERR โ€” Address not mapped to object

๐ŸšŒ SIGBUS

  • BUS_ADRALN โ€” Invalid address alignment
  • BUS_ADRERR โ€” Nonexistent physical address
  • BUS_OBJERR โ€” Object-specific hardware error

๐Ÿชค SIGTRAP

  • TRAP_BRKPT โ€” Process breakpoint
  • TRAP_CHLD โ€” Process child trap
  • TRAP_DBREG โ€” Process hardware debug register trap
  • TRAP_EXEC โ€” Process exec trap
  • TRAP_LWP โ€” Process LWP trap
  • TRAP_SCE โ€” Process syscall entry trap
  • TRAP_SCX โ€” Process syscall exit trap
  • TRAP_TRACE โ€” Process trace trap

๐Ÿ‘ถ SIGCHLD

  • CLD_CONTINUED โ€” Stopped child has continued
  • CLD_DUMPED โ€” Child has terminated abnormally and created a core file
  • CLD_EXITED โ€” Child has exited
  • CLD_KILLED โ€” Child has terminated abnormally but did not create a core file
  • CLD_STOPPED โ€” Child has stopped
  • CLD_TRAPPED โ€” Traced child has trapped

๐Ÿ“ก SIGIO

  • POLL_ERR โ€” I/O error
  • POLL_HUP โ€” Device disconnected
  • POLL_IN โ€” Data input available
  • POLL_MSG โ€” Input message available
  • POLL_OUT โ€” Output buffers available
  • POLL_PRI โ€” High priority input available

for SIGILL, SIGFPE, SIGBUS and SIGSEGV the siginfo structure contains these additional members:

void *si_addr;
int si_trap;

si_addr contains the address of the faulting instruction or data, and si_trap contains a hardware specific reason ๐Ÿ”ฅ

for SIGTRAP and TRAP_BRKPT, TRAP_TRACE or TRAP_DBREG the siginfo structure contains these additional members:

void *si_addr;
int si_trap;

si_addr contains the address of the faulting data, and si_trap contains a hardware specific reason ๐ŸŽ€

for SIGTRAP and TRAP_SCE or TRAP_SCX the siginfo structure contains these additional members:

int si_sysnum;
int si_retval[2];
int si_error;
uint64_t si_args[8];

si_sysnum contains the syscall number, si_retval contains the syscall return value (meaningful for TRAP_SCX only), si_error contains the syscall error value (meaningful for TRAP_SCX only), and si_args[8] contains the syscall arguments ๐Ÿงš

for SIGIO the siginfo structure contains these additional members:

int si_fd;
long si_band;

the si_fd argument contains the file descriptor number on which the operation was completed, and the si_band field contains the side and priority of the operation as described above ๐Ÿ“ก

finally, for SIGCHLD the siginfo structure contains these additional members:

pid_t si_pid;
uid_t si_uid;
int si_status;
clock_t si_utime;
clock_t si_stime;

the si_pid field contains the pid of the process whoโ€™s status changed, the si_uid field contains the user id of that process, and the si_status field contains either the exit code of the process (for CLD_EXITED), or the signal number received by the process. waitid(2), waitpid(2), and the si_utime and si_stime fields contain the user and system process accounting time ๐Ÿ‘‘

๐Ÿฆ‹ STANDARDS ๐Ÿฆ‹

the <cyan>siginfo</cyan> type conforms to X/Open System Interfaces and Headers Issue 5 (โ€œXSH5โ€).

signals specifying SI_LWP or SI_NOINFO are NetBSD extensions.

the TRAP_CHLD, TRAP_DBREG, TRAP_EXEC, TRAP_LWP, TRAP_SCE and TRAP_SCX signal specific reasons of SIGTRAP are NetBSD extensions ๐Ÿ’œ

๐ŸŽ€ HISTORY ๐ŸŽ€

the <lavender>siginfo</lavender> functionality first appeared in AT&T System V Release 4 UNIX.

TRAP_CHLD, TRAP_DBREG, TRAP_EXEC, TRAP_LWP, TRAP_SCE and TRAP_SCX first appeared in NetBSD 8.

the additional parameters with syscall information in TRAP_SCE and TRAP_SCX first appeared in NetBSD 9 ๐ŸŒˆ


thatโ€™s the whole tea, bestie ๐Ÿซถ this page is from Debian, dated May 25, 2019, and itโ€™s SIGINFO(2). go decode those signals and absolutely slay ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from