siginfo_t
StructureThe
siginfo_t
structure provides a lot of information to the signal handler, sa_sigaction
:
typedef struct siginfo_t {
int si_signo; // Signal number -------------------> Same as the first argument to sa_sigaction.
int si_errno; // Error value ---------------------> If nonzero, contains the error code associated with this signal.
int si_code; // Signal code ---------------------> An explanation of why/where the process received the signal.
pid_t si_pid; // Sending process's PID -----------> For SIGCHLD, the pid of the process that terminated.
uid_t si_uid; // Sending process's real UID ------> For SIGCHLD, the owner uid of the process that terminated.
int si_status; // Exit value or signal ------------> For SIGCHLD, the exit status of the process that terminated.
clock_t si_utime; // User time consumed --------------> For SIGCHLD, the user time consumed of the process that terminated.
clock_t si_stime; // System time consumed ------------> For SIGCHLD, the system time consumed of the process that terminated.
sigval si_value; // Signal's payload value ----------> A union of si_int and si_ptr (see fields below.)
int si_int; // POSIX.1b signal -----------------> Payload (data you wish to pass) in a form of an integer.
void *si_ptr; // POSIX.1b signal -----------------> Payload (data you wish to pass) in a form of a void pointer.
void *si_addr; // Memory location causeing fault --> For SIGBUS, SIGFPE, SIGILL, SIGSEGV, and SIGTRAP only.
long si_band; // Band event ----------------------> For SIGPOLL (pollable events), out-of-band/priority info for si_fd.
int si_fd; // File descriptor -----------------> For SIGPOLL, the fd for the file whose operation completed.
};