The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/signalvar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: signalvar.h,v 1.73 2008/02/19 12:24:34 yamt Exp $      */
    2 
    3 /*
    4  * Copyright (c) 1991, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the University nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  *      @(#)signalvar.h 8.6 (Berkeley) 2/19/95
   32  */
   33 
   34 #ifndef _SYS_SIGNALVAR_H_               /* tmp for user.h */
   35 #define _SYS_SIGNALVAR_H_
   36 
   37 #include <sys/siginfo.h>
   38 #include <sys/queue.h>
   39 #include <sys/mutex.h>
   40 
   41 /*
   42  * Kernel signal definitions and data structures,
   43  * not exported to user programs.
   44  */
   45 
   46 /*
   47  * Queue of signals.
   48  */
   49 typedef CIRCLEQ_HEAD(ksiginfoq, ksiginfo) ksiginfoq_t;
   50 
   51 /*
   52  * Process signal actions, possibly shared between processes.
   53  */
   54 struct sigacts {
   55         struct sigact_sigdesc {
   56                 struct sigaction sd_sigact;
   57                 const void      *sd_tramp;
   58                 int             sd_vers;
   59         } sa_sigdesc[NSIG];             /* disposition of signals */
   60 
   61         int             sa_refcnt;      /* reference count */
   62         kmutex_t        sa_mutex;       /* lock on sa_refcnt */
   63 };
   64 
   65 /*
   66  * Pending signals, per LWP and per process.
   67  */
   68 typedef struct sigpend {
   69         ksiginfoq_t     sp_info;
   70         sigset_t        sp_set;
   71 } sigpend_t;
   72 
   73 /*
   74  * Process signal state.
   75  */
   76 struct sigctx {
   77         int             ps_signo;       /* for core dump/debugger XXX */
   78         int             ps_code;        /* for core dump/debugger XXX */
   79         int             ps_lwp;         /* for core dump/debugger XXX */
   80         void            *ps_sigcode;    /* address of signal trampoline */
   81         sigset_t        ps_sigignore;   /* Signals being ignored. */
   82         sigset_t        ps_sigcatch;    /* Signals being caught by user. */
   83 };
   84 
   85 /*
   86  * Storage for items that may be either per-LWP (1:1 threads) or
   87  * per-process (SA threads).
   88  */
   89 typedef struct sigstore {
   90         stack_t         ss_stk;         /* p: sp & on stack state variable */
   91         sigset_t        ss_mask;        /* p: signal mask */
   92 } sigstore_t;
   93 
   94 /* additional signal action values, used only temporarily/internally */
   95 #define SIG_CATCH       (void (*)(int))2
   96 
   97 /*
   98  * get signal action for process and signal; currently only for current process
   99  */
  100 #define SIGACTION(p, sig)       (p->p_sigacts->sa_sigdesc[(sig)].sd_sigact)
  101 #define SIGACTION_PS(ps, sig)   (ps->sa_sigdesc[(sig)].sd_sigact)
  102 
  103 /*
  104  * Signal properties and actions.
  105  * The array below categorizes the signals and their default actions
  106  * according to the following properties:
  107  */
  108 #define SA_KILL         0x0001          /* terminates process by default */
  109 #define SA_CORE         0x0002          /* ditto and coredumps */
  110 #define SA_STOP         0x0004          /* suspend process */
  111 #define SA_TTYSTOP      0x0008          /* ditto, from tty */
  112 #define SA_IGNORE       0x0010          /* ignore by default */
  113 #define SA_CONT         0x0020          /* continue if suspended */
  114 #define SA_CANTMASK     0x0040          /* non-maskable, catchable */
  115 #define SA_NORESET      0x0080          /* not reset when caught */
  116 #define SA_TOLWP        0x0100          /* to LWP that generated, if local */
  117 #define SA_TOALL        0x0200          /* always to all LWPs */
  118 
  119 #ifdef _KERNEL
  120 
  121 #include <sys/systm.h>                  /* for copyin_t/copyout_t */
  122 
  123 extern sigset_t contsigmask, stopsigmask, sigcantmask;
  124 
  125 struct vnode;
  126 
  127 /*
  128  * Machine-independent functions:
  129  */
  130 int     coredump(struct lwp *, const char *);
  131 int     coredump_netbsd(struct lwp *, void *);
  132 void    execsigs(struct proc *);
  133 void    gsignal(int, int);
  134 void    kgsignal(int, struct ksiginfo *, void *);
  135 int     issignal(struct lwp *);
  136 void    pgsignal(struct pgrp *, int, int);
  137 void    kpgsignal(struct pgrp *, struct ksiginfo *, void *, int);
  138 void    postsig(int);
  139 void    psignal(struct proc *, int);
  140 void    kpsignal(struct proc *, struct ksiginfo *, void *);
  141 void    child_psignal(struct proc *, int);
  142 void    siginit(struct proc *);
  143 void    trapsignal(struct lwp *, struct ksiginfo *);
  144 void    sigexit(struct lwp *, int);
  145 void    killproc(struct proc *, const char *);
  146 void    setsigvec(struct proc *, int, struct sigaction *);
  147 int     killpg1(struct lwp *, struct ksiginfo *, int, int);
  148 void    proc_unstop(struct proc *p);
  149 
  150 int     sigaction1(struct lwp *, int, const struct sigaction *,
  151             struct sigaction *, const void *, int);
  152 int     sigprocmask1(struct lwp *, int, const sigset_t *, sigset_t *);
  153 void    sigpending1(struct lwp *, sigset_t *);
  154 int     sigsuspend1(struct lwp *, const sigset_t *);
  155 int     sigaltstack1(struct lwp *, const struct sigaltstack *,
  156             struct sigaltstack *);
  157 int     sigismasked(struct lwp *, int);
  158 
  159 int     sigget(sigpend_t *, ksiginfo_t *, int, const sigset_t *);
  160 void    sigclear(sigpend_t *, const sigset_t *, ksiginfoq_t *);
  161 void    sigclearall(struct proc *, const sigset_t *, ksiginfoq_t *);
  162 
  163 void    kpsignal2(struct proc *, ksiginfo_t *);
  164 
  165 void    signal_init(void);
  166 
  167 struct sigacts  *sigactsinit(struct proc *, int);
  168 void    sigactsunshare(struct proc *);
  169 void    sigactsfree(struct sigacts *);
  170 
  171 void    kpsendsig(struct lwp *, const struct ksiginfo *, const sigset_t *);
  172 void    sendsig_reset(struct lwp *, int);
  173 
  174 siginfo_t *siginfo_alloc(int);
  175 void    siginfo_free(void *);
  176 
  177 ksiginfo_t      *ksiginfo_alloc(struct proc *, ksiginfo_t *, int);
  178 void    ksiginfo_free(ksiginfo_t *);
  179 void    ksiginfo_queue_drain0(ksiginfoq_t *);
  180 
  181 struct sys___sigtimedwait_args;
  182 int     __sigtimedwait1(struct lwp *, const struct sys___sigtimedwait_args *, register_t *, copyout_t,
  183     copyin_t, copyout_t);
  184 
  185 void    signotify(struct lwp *);
  186 int     sigispending(struct lwp *, int);
  187 
  188 /*
  189  * Machine-dependent functions:
  190  */
  191 void    sendsig(const struct ksiginfo *, const sigset_t *);
  192 
  193 extern  struct pool ksiginfo_pool;
  194 
  195 /*
  196  * firstsig:
  197  *
  198  *      Return the first signal in a signal set.
  199  */
  200 static inline int
  201 firstsig(const sigset_t *ss)
  202 {
  203         int sig;
  204 
  205         sig = ffs(ss->__bits[0]);
  206         if (sig != 0)
  207                 return (sig);
  208 #if NSIG > 33
  209         sig = ffs(ss->__bits[1]);
  210         if (sig != 0)
  211                 return (sig + 32);
  212 #endif
  213 #if NSIG > 65
  214         sig = ffs(ss->__bits[2]);
  215         if (sig != 0)
  216                 return (sig + 64);
  217 #endif
  218 #if NSIG > 97
  219         sig = ffs(ss->__bits[3]);
  220         if (sig != 0)
  221                 return (sig + 96);
  222 #endif
  223         return (0);
  224 }
  225 
  226 static inline void
  227 ksiginfo_queue_init(ksiginfoq_t *kq)
  228 {
  229         CIRCLEQ_INIT(kq);
  230 }
  231 
  232 static inline void
  233 ksiginfo_queue_drain(ksiginfoq_t *kq)
  234 {
  235         if (!CIRCLEQ_EMPTY(kq))
  236                 ksiginfo_queue_drain0(kq);
  237 }
  238 
  239 #endif  /* _KERNEL */
  240 
  241 #ifdef  _KERNEL
  242 #ifdef  SIGPROP
  243 const int sigprop[NSIG] = {
  244         0,                                      /* 0 unused */
  245         SA_KILL,                                /* 1 SIGHUP */
  246         SA_KILL,                                /* 2 SIGINT */
  247         SA_KILL|SA_CORE,                        /* 3 SIGQUIT */
  248         SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP,    /* 4 SIGILL */
  249         SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP,    /* 5 SIGTRAP */
  250         SA_KILL|SA_CORE,                        /* 6 SIGABRT */
  251         SA_KILL|SA_CORE|SA_TOLWP,               /* 7 SIGEMT */
  252         SA_KILL|SA_CORE|SA_TOLWP,               /* 8 SIGFPE */
  253         SA_KILL|SA_CANTMASK|SA_TOALL,           /* 9 SIGKILL */
  254         SA_KILL|SA_CORE|SA_TOLWP,               /* 10 SIGBUS */
  255         SA_KILL|SA_CORE|SA_TOLWP,               /* 11 SIGSEGV */
  256         SA_KILL|SA_CORE|SA_TOLWP,               /* 12 SIGSYS */
  257         SA_KILL,                                /* 13 SIGPIPE */
  258         SA_KILL,                                /* 14 SIGALRM */
  259         SA_KILL,                                /* 15 SIGTERM */
  260         SA_IGNORE,                              /* 16 SIGURG */
  261         SA_STOP|SA_CANTMASK|SA_TOALL,           /* 17 SIGSTOP */
  262         SA_STOP|SA_TTYSTOP|SA_TOALL,            /* 18 SIGTSTP */
  263         SA_IGNORE|SA_CONT|SA_TOALL,             /* 19 SIGCONT */
  264         SA_IGNORE,                              /* 20 SIGCHLD */
  265         SA_STOP|SA_TTYSTOP|SA_TOALL,            /* 21 SIGTTIN */
  266         SA_STOP|SA_TTYSTOP|SA_TOALL,            /* 22 SIGTTOU */
  267         SA_IGNORE,                              /* 23 SIGIO */
  268         SA_KILL,                                /* 24 SIGXCPU */
  269         SA_KILL,                                /* 25 SIGXFSZ */
  270         SA_KILL,                                /* 26 SIGVTALRM */
  271         SA_KILL,                                /* 27 SIGPROF */
  272         SA_IGNORE,                              /* 28 SIGWINCH  */
  273         SA_IGNORE,                              /* 29 SIGINFO */
  274         SA_KILL,                                /* 30 SIGUSR1 */
  275         SA_KILL,                                /* 31 SIGUSR2 */
  276         SA_IGNORE|SA_NORESET,                   /* 32 SIGPWR */
  277         SA_KILL,                                /* 33 SIGRTMIN + 0 */
  278         SA_KILL,                                /* 34 SIGRTMIN + 1 */
  279         SA_KILL,                                /* 35 SIGRTMIN + 2 */
  280         SA_KILL,                                /* 36 SIGRTMIN + 3 */
  281         SA_KILL,                                /* 37 SIGRTMIN + 4 */
  282         SA_KILL,                                /* 38 SIGRTMIN + 5 */
  283         SA_KILL,                                /* 39 SIGRTMIN + 6 */
  284         SA_KILL,                                /* 40 SIGRTMIN + 7 */
  285         SA_KILL,                                /* 41 SIGRTMIN + 8 */
  286         SA_KILL,                                /* 42 SIGRTMIN + 9 */
  287         SA_KILL,                                /* 43 SIGRTMIN + 10 */
  288         SA_KILL,                                /* 44 SIGRTMIN + 11 */
  289         SA_KILL,                                /* 45 SIGRTMIN + 12 */
  290         SA_KILL,                                /* 46 SIGRTMIN + 13 */
  291         SA_KILL,                                /* 47 SIGRTMIN + 14 */
  292         SA_KILL,                                /* 48 SIGRTMIN + 15 */
  293         SA_KILL,                                /* 49 SIGRTMIN + 16 */
  294         SA_KILL,                                /* 50 SIGRTMIN + 17 */
  295         SA_KILL,                                /* 51 SIGRTMIN + 18 */
  296         SA_KILL,                                /* 52 SIGRTMIN + 19 */
  297         SA_KILL,                                /* 53 SIGRTMIN + 20 */
  298         SA_KILL,                                /* 54 SIGRTMIN + 21 */
  299         SA_KILL,                                /* 55 SIGRTMIN + 22 */
  300         SA_KILL,                                /* 56 SIGRTMIN + 23 */
  301         SA_KILL,                                /* 57 SIGRTMIN + 24 */
  302         SA_KILL,                                /* 58 SIGRTMIN + 25 */
  303         SA_KILL,                                /* 59 SIGRTMIN + 26 */
  304         SA_KILL,                                /* 60 SIGRTMIN + 27 */
  305         SA_KILL,                                /* 61 SIGRTMIN + 28 */
  306         SA_KILL,                                /* 62 SIGRTMIN + 29 */
  307         SA_KILL,                                /* 63 SIGRTMIN + 30 */
  308 };
  309 #undef  SIGPROP
  310 #else
  311 extern const int sigprop[NSIG];
  312 #endif  /* SIGPROP */
  313 #endif  /* _KERNEL */
  314 #endif  /* !_SYS_SIGNALVAR_H_ */

Cache object: c2659acd6097804d3b74f48ab10ff588


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.