DOCUMENT ID: 1477-02

SYNOPSIS:    Getting Signal Information

OS RELEASE:  Solaris 2.x

PRODUCT:     

KEYWORDS:    signal process erno code


DESCRIPTION:

This is a description of the process of getting Signal information


SOLUTION:

A process can arrange for a signal handling function to receive three
arguments.  One of these includes a pointer to a structure of type
"siginfo_t".  By using the information in this structure, a process can
obtain an explanation of why a signal was generated.  Another system
call that uses a similar scheme is "waitid".  This system call suspends
the process until one of its children changes its state.  When this
happens, "waitid" returns, after setting a p[pointer to a "siginfo_t
structure containing the explanation for why the child changed it's
state. 

The siginfo structure is complicated because it is made up of a union of
several data abstractions.  Thus, it is best shown in its coded form as
it is defined in . 

The information in the structure always contains the following
variables:

        int si_signo;   /* generated signal number */
        int si_errno;   /* non-zero errno number */
        int si_code;    /* reason/cause code */

The value of "si_signo" represents the signal type that was generated. 
If "si_errno" is non-zero, its value represents an errno code.  The
"si_code variable contains a cause-code.  A program should first read
"si_signo" to find out how to interpret "si_code".  If "si_code" is less
than or equal to zero, then the signal was generated by a process
running in user-mode.  This means that the "siginfo" structure contains
the following additional information:

        pid_t si_pid;   /* Process ID of sending process */
        uid_t si_uid;   /* User ID of sending process */

If "si_code" is greater than zero then its interpretation depends on the
signal received and the value of the cause code identifier, "si_signo". 
For more information about "siginfo", see siginfo(5). 


Interpretation of si_code in siginfo structure.
______________________________________________________________________________
Generated               Cause                   Description                
Signal                  Code                    or Reason                  
------------------------------------------------------------------------------

SIGILL                  ILL_ILLOPC              Illegal opcode
                        ILL_ILLOPN              Illegal operand
                        ILL_ILLADR              Illegal addressing mode
                        ILL_ILLTRP              Illegal trap
                        ILL_PRVOPC              Privileged opcode
                        ILL_PRVREG              Privileged register
                        ILL_COPROC              Coprocessor error
                        ILL_BADSTK              Internal stack error
------------------------------------------------------------------------------
SIGFPE                  FPE_INTDIV              Integer divided 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              Non-existent physical address
                        BUS_OBJERR              Object specific hardware error
------------------------------------------------------------------------------
SIGTRAP                 TRAP_BRKPT              Process breakpoint
                        TRAP_TRACE              Process trap point
------------------------------------------------------------------------------
SIGCHLD                 CLD_EXITED              Child has exited
                        CLD_KILLED              Child was killed
                        CLD_DUMPED              Child terminated abnormally
                        CLD_TRAPPED             Traced child has trapped
                        CLD_STOPPED             Child has stopped
                        CLD_CONTINUED           Stopped child had 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
------------------------------------------------------------------------------


DATE APPROVED: 07/28/95