Back to index

glibc  2.9
siginfo.h
Go to the documentation of this file.
00001 /* siginfo_t, sigevent and constants.  Linux/Alpha version.
00002    Copyright (C) 1997-2002, 2003 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #if !defined _SIGNAL_H && !defined __need_siginfo_t \
00021     && !defined __need_sigevent_t
00022 # error "Never include this file directly.  Use <signal.h> instead"
00023 #endif
00024 
00025 #if (!defined __have_sigval_t \
00026      && (defined _SIGNAL_H || defined __need_siginfo_t \
00027         || defined __need_sigevent_t))
00028 # define __have_sigval_t    1
00029 
00030 /* Type for data associated with a signal.  */
00031 typedef union sigval
00032   {
00033     int sival_int;
00034     void *sival_ptr;
00035   } sigval_t;
00036 #endif
00037 
00038 #if (!defined __have_siginfo_t \
00039      && (defined _SIGNAL_H || defined __need_siginfo_t))
00040 # define __have_siginfo_t   1
00041 
00042 # define __SI_MAX_SIZE     128
00043 # define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
00044 
00045 typedef struct siginfo
00046   {
00047     int si_signo;           /* Signal number.  */
00048     int si_errno;           /* If non-zero, an errno value associated with
00049                                this signal, as defined in <errno.h>.  */
00050     int si_code;            /* Signal code.  */
00051 
00052     union
00053       {
00054        int _pad[__SI_PAD_SIZE];
00055 
00056         /* kill().  */
00057        struct
00058          {
00059            __pid_t si_pid;  /* Sending process ID.  */
00060            __uid_t si_uid;  /* Real user ID of sending process.  */
00061          } _kill;
00062 
00063        /* POSIX.1b timers.  */
00064        struct
00065          {
00066            int si_tid;             /* Timer ID.  */
00067            int si_overrun;  /* Overrun count.  */
00068            sigval_t si_sigval;     /* Signal value.  */
00069          } _timer;
00070 
00071        /* POSIX.1b signals.  */
00072        struct
00073          {
00074            __pid_t si_pid;  /* Sending process ID.  */
00075            __uid_t si_uid;  /* Real user ID of sending process.  */
00076            sigval_t si_sigval;     /* Signal value.  */
00077          } _rt;
00078 
00079        /* SIGCHLD.  */
00080        struct
00081          {
00082            __pid_t si_pid;  /* Which child.  */
00083            __uid_t si_uid;  /* Real user ID of sending process.  */
00084            int si_status;   /* Exit value or signal.  */
00085            __clock_t si_utime;
00086            __clock_t si_stime;
00087          } _sigchld;
00088 
00089        /* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */
00090        struct
00091          {
00092            void *si_addr;   /* Faulting insn/memory ref.  */
00093          } _sigfault;
00094 
00095        /* SIGPOLL.  */
00096        struct
00097          {
00098            int si_band;     /* Band event for SIGPOLL.  */
00099            int si_fd;
00100          } _sigpoll;
00101       } _sifields;
00102   } siginfo_t;
00103 
00104 
00105 /* X/Open requires some more fields with fixed names.  */
00106 # define si_pid             _sifields._kill.si_pid
00107 # define si_uid             _sifields._kill.si_uid
00108 # define si_timerid  _sifields._timer.si_tid
00109 # define si_overrun  _sifields._timer.si_overrun
00110 # define si_status   _sifields._sigchld.si_status
00111 # define si_utime    _sifields._sigchld.si_utime
00112 # define si_stime    _sifields._sigchld.si_stime
00113 # define si_value    _sifields._rt.si_sigval
00114 # define si_int             _sifields._rt.si_sigval.sival_int
00115 # define si_ptr             _sifields._rt.si_sigval.sival_ptr
00116 # define si_addr     _sifields._sigfault.si_addr
00117 # define si_band     _sifields._sigpoll.si_band
00118 # define si_fd              _sifields._sigpoll.si_fd
00119 
00120 
00121 /* Values for `si_code'.  Positive values are reserved for kernel-generated
00122    signals.  */
00123 enum
00124 {
00125   SI_ASYNCNL = -60,         /* Sent by asynch name lookup completion.  */
00126 # define SI_ASYNCNL  SI_ASYNCNL
00127   SI_TKILL = -6,            /* Sent by tkill.  */
00128 # define SI_TKILL    SI_TKILL
00129   SI_SIGIO,                 /* Sent by queued SIGIO. */
00130 # define SI_SIGIO    SI_SIGIO
00131   SI_ASYNCIO,               /* Sent by AIO completion.  */
00132 # define SI_ASYNCIO  SI_ASYNCIO
00133   SI_MESGQ,                 /* Sent by real time mesq state change.  */
00134 # define SI_MESGQ    SI_MESGQ
00135   SI_TIMER,                 /* Sent by timer expiration.  */
00136 # define SI_TIMER    SI_TIMER
00137   SI_QUEUE,                 /* Sent by sigqueue.  */
00138 # define SI_QUEUE    SI_QUEUE
00139   SI_USER,                  /* Sent by kill, sigsend, raise.  */
00140 # define SI_USER     SI_USER
00141   SI_KERNEL = 0x80          /* Send by kernel.  */
00142 #define SI_KERNEL    SI_KERNEL
00143 };
00144 
00145 
00146 /* `si_code' values for SIGILL signal.  */
00147 enum
00148 {
00149   ILL_ILLOPC = 1,           /* Illegal opcode.  */
00150 # define ILL_ILLOPC  ILL_ILLOPC
00151   ILL_ILLOPN,               /* Illegal operand.  */
00152 # define ILL_ILLOPN  ILL_ILLOPN
00153   ILL_ILLADR,               /* Illegal addressing mode.  */
00154 # define ILL_ILLADR  ILL_ILLADR
00155   ILL_ILLTRP,               /* Illegal trap. */
00156 # define ILL_ILLTRP  ILL_ILLTRP
00157   ILL_PRVOPC,               /* Privileged opcode.  */
00158 # define ILL_PRVOPC  ILL_PRVOPC
00159   ILL_PRVREG,               /* Privileged register.  */
00160 # define ILL_PRVREG  ILL_PRVREG
00161   ILL_COPROC,               /* Coprocessor error.  */
00162 # define ILL_COPROC  ILL_COPROC
00163   ILL_BADSTK                /* Internal stack error.  */
00164 # define ILL_BADSTK  ILL_BADSTK
00165 };
00166 
00167 /* `si_code' values for SIGFPE signal.  */
00168 enum
00169 {
00170   FPE_INTDIV = 1,           /* Integer divide by zero.  */
00171 # define FPE_INTDIV  FPE_INTDIV
00172   FPE_INTOVF,               /* Integer overflow.  */
00173 # define FPE_INTOVF  FPE_INTOVF
00174   FPE_FLTDIV,               /* Floating point divide by zero.  */
00175 # define FPE_FLTDIV  FPE_FLTDIV
00176   FPE_FLTOVF,               /* Floating point overflow.  */
00177 # define FPE_FLTOVF  FPE_FLTOVF
00178   FPE_FLTUND,               /* Floating point underflow.  */
00179 # define FPE_FLTUND  FPE_FLTUND
00180   FPE_FLTRES,               /* Floating point inexact result.  */
00181 # define FPE_FLTRES  FPE_FLTRES
00182   FPE_FLTINV,               /* Floating point invalid operation.  */
00183 # define FPE_FLTINV  FPE_FLTINV
00184   FPE_FLTSUB                /* Subscript out of range.  */
00185 # define FPE_FLTSUB  FPE_FLTSUB
00186 };
00187 
00188 /* `si_code' values for SIGSEGV signal.  */
00189 enum
00190 {
00191   SEGV_MAPERR = 1,          /* Address not mapped to object.  */
00192 # define SEGV_MAPERR SEGV_MAPERR
00193   SEGV_ACCERR               /* Invalid permissions for mapped object.  */
00194 # define SEGV_ACCERR SEGV_ACCERR
00195 };
00196 
00197 /* `si_code' values for SIGBUS signal.  */
00198 enum
00199 {
00200   BUS_ADRALN = 1,           /* Invalid address alignment.  */
00201 # define BUS_ADRALN  BUS_ADRALN
00202   BUS_ADRERR,               /* Non-existant physical address.  */
00203 # define BUS_ADRERR  BUS_ADRERR
00204   BUS_OBJERR                /* Object specific hardware error.  */
00205 # define BUS_OBJERR  BUS_OBJERR
00206 };
00207 
00208 /* `si_code' values for SIGTRAP signal.  */
00209 enum
00210 {
00211   TRAP_BRKPT = 1,           /* Process breakpoint.  */
00212 # define TRAP_BRKPT  TRAP_BRKPT
00213   TRAP_TRACE                /* Process trace trap.  */
00214 # define TRAP_TRACE  TRAP_TRACE
00215 };
00216 
00217 /* `si_code' values for SIGCHLD signal.  */
00218 enum
00219 {
00220   CLD_EXITED = 1,           /* Child has exited.  */
00221 # define CLD_EXITED  CLD_EXITED
00222   CLD_KILLED,               /* Child was killed.  */
00223 # define CLD_KILLED  CLD_KILLED
00224   CLD_DUMPED,               /* Child terminated abnormally.  */
00225 # define CLD_DUMPED  CLD_DUMPED
00226   CLD_TRAPPED,                     /* Traced child has trapped.  */
00227 # define CLD_TRAPPED CLD_TRAPPED
00228   CLD_STOPPED,                     /* Child has stopped.  */
00229 # define CLD_STOPPED CLD_STOPPED
00230   CLD_CONTINUED                    /* Stopped child has continued.  */
00231 # define CLD_CONTINUED      CLD_CONTINUED
00232 };
00233 
00234 /* `si_code' values for SIGPOLL signal.  */
00235 enum
00236 {
00237   POLL_IN = 1,                     /* Data input available.  */
00238 # define POLL_IN     POLL_IN
00239   POLL_OUT,                 /* Output buffers available.  */
00240 # define POLL_OUT    POLL_OUT
00241   POLL_MSG,                 /* Input message available.   */
00242 # define POLL_MSG    POLL_MSG
00243   POLL_ERR,                 /* I/O error.  */
00244 # define POLL_ERR    POLL_ERR
00245   POLL_PRI,                 /* High priority input available.  */
00246 # define POLL_PRI    POLL_PRI
00247   POLL_HUP                  /* Device disconnected.  */
00248 # define POLL_HUP    POLL_HUP
00249 };
00250 
00251 # undef __need_siginfo_t
00252 #endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t).  */
00253 
00254 
00255 #if (defined _SIGNAL_H || defined __need_sigevent_t) \
00256     && !defined __have_sigevent_t
00257 # define __have_sigevent_t  1
00258 
00259 /* Structure to transport application-defined values with signals.  */
00260 # define __SIGEV_MAX_SIZE   64
00261 # define __SIGEV_PAD_SIZE   ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
00262 
00263 typedef struct sigevent
00264   {
00265     sigval_t sigev_value;
00266     int sigev_signo;
00267     int sigev_notify;
00268 
00269     union
00270       {
00271        int _pad[__SIGEV_PAD_SIZE];
00272 
00273        /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the
00274           thread to receive the signal.  */
00275        __pid_t _tid;
00276 
00277        struct
00278          {
00279            void (*_function) (sigval_t);  /* Function to start.  */
00280            void *_attribute;                     /* Really pthread_attr_t.  */
00281          } _sigev_thread;
00282       } _sigev_un;
00283   } sigevent_t;
00284 
00285 /* POSIX names to access some of the members.  */
00286 # define sigev_notify_function   _sigev_un._sigev_thread._function
00287 # define sigev_notify_attributes _sigev_un._sigev_thread._attribute
00288 
00289 /* `sigev_notify' values.  */
00290 enum
00291 {
00292   SIGEV_SIGNAL = 0,         /* Notify via signal.  */
00293 # define SIGEV_SIGNAL       SIGEV_SIGNAL
00294   SIGEV_NONE,               /* Other notification: meaningless.  */
00295 # define SIGEV_NONE  SIGEV_NONE
00296   SIGEV_THREAD,                    /* Deliver via thread creation.  */
00297 # define SIGEV_THREAD       SIGEV_THREAD
00298 
00299   SIGEV_THREAD_ID = 4              /* Send signal to specific thread.  */
00300 #define SIGEV_THREAD_ID     SIGEV_THREAD_ID
00301 };
00302 
00303 #endif /* have _SIGNAL_H.  */