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 /*
    2  * Copyright (c) 1991, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 3. All advertising materials mentioning features or use of this software
   14  *    must display the following acknowledgement:
   15  *      This product includes software developed by the University of
   16  *      California, Berkeley and its contributors.
   17  * 4. Neither the name of the University nor the names of its contributors
   18  *    may be used to endorse or promote products derived from this software
   19  *    without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   31  * SUCH DAMAGE.
   32  *
   33  *      @(#)signalvar.h 8.6 (Berkeley) 2/19/95
   34  * $FreeBSD: releng/5.2/sys/sys/signalvar.h 122386 2003-11-10 03:11:08Z davidxu $
   35  */
   36 
   37 #ifndef _SYS_SIGNALVAR_H_
   38 #define _SYS_SIGNALVAR_H_
   39 
   40 #include <sys/queue.h>
   41 #include <sys/_lock.h>
   42 #include <sys/_mutex.h>
   43 #include <sys/signal.h>
   44 
   45 /*
   46  * Kernel signal definitions and data structures,
   47  * not exported to user programs.
   48  */
   49 
   50 /*
   51  * Logical process signal actions and state, needed only within the process
   52  * The mapping between sigacts and proc structures is 1:1 except for rfork()
   53  * processes masquerading as threads which use one structure for the whole
   54  * group.  All members are locked by the included mutex.  The reference count
   55  * and mutex must be last for the bcopy in sigacts_copy() to work.
   56  */
   57 struct sigacts {
   58         sig_t   ps_sigact[_SIG_MAXSIG]; /* Disposition of signals. */
   59         sigset_t ps_catchmask[_SIG_MAXSIG];     /* Signals to be blocked. */
   60         sigset_t ps_sigonstack;         /* Signals to take on sigstack. */
   61         sigset_t ps_sigintr;            /* Signals that interrupt syscalls. */
   62         sigset_t ps_sigreset;           /* Signals that reset when caught. */
   63         sigset_t ps_signodefer;         /* Signals not masked while handled. */
   64         sigset_t ps_siginfo;            /* Signals that want SA_SIGINFO args. */
   65         sigset_t ps_sigignore;          /* Signals being ignored. */
   66         sigset_t ps_sigcatch;           /* Signals being caught by user. */
   67         sigset_t ps_freebsd4;           /* signals using freebsd4 ucontext. */
   68         sigset_t ps_osigset;            /* Signals using <= 3.x osigset_t. */
   69         sigset_t ps_usertramp;          /* SunOS compat; libc sigtramp. XXX */
   70         int     ps_flag;
   71         int     ps_refcnt;
   72         struct mtx ps_mtx;
   73 };
   74 
   75 #define PS_NOCLDWAIT    0x0001  /* No zombies if child dies */
   76 #define PS_NOCLDSTOP    0x0002  /* No SIGCHLD when children stop. */
   77 #define PS_CLDSIGIGN    0x0004  /* The SIGCHLD handler is SIG_IGN. */
   78 
   79 #if defined(_KERNEL) && defined(COMPAT_43)
   80 /*
   81  * Compatibility.
   82  */
   83 typedef struct {
   84         struct osigcontext si_sc;
   85         int             si_signo;
   86         int             si_code;
   87         union sigval    si_value;
   88 } osiginfo_t;
   89 
   90 struct osigaction {
   91         union {
   92                 void    (*__sa_handler)(int);
   93                 void    (*__sa_sigaction)(int, osiginfo_t *, void *);
   94         } __sigaction_u;                /* signal handler */
   95         osigset_t       sa_mask;        /* signal mask to apply */
   96         int             sa_flags;       /* see signal options below */
   97 };
   98 
   99 typedef void __osiginfohandler_t(int, osiginfo_t *, void *);
  100 #endif /* _KERNEL && COMPAT_43 */
  101 
  102 /* additional signal action values, used only temporarily/internally */
  103 #define SIG_CATCH       ((__sighandler_t *)2)
  104 #define SIG_HOLD        ((__sighandler_t *)3)
  105 
  106 /*
  107  * get signal action for process and signal; currently only for current process
  108  */
  109 #define SIGACTION(p, sig)       (p->p_sigacts->ps_sigact[_SIG_IDX(sig)])
  110 
  111 /*
  112  * sigset_t manipulation macros
  113  */
  114 #define SIGADDSET(set, signo)                                           \
  115         ((set).__bits[_SIG_WORD(signo)] |= _SIG_BIT(signo))
  116 
  117 #define SIGDELSET(set, signo)                                           \
  118         ((set).__bits[_SIG_WORD(signo)] &= ~_SIG_BIT(signo))
  119 
  120 #define SIGEMPTYSET(set)                                                \
  121         do {                                                            \
  122                 int __i;                                                \
  123                 for (__i = 0; __i < _SIG_WORDS; __i++)                  \
  124                         (set).__bits[__i] = 0;                          \
  125         } while (0)
  126 
  127 #define SIGFILLSET(set)                                                 \
  128         do {                                                            \
  129                 int __i;                                                \
  130                 for (__i = 0; __i < _SIG_WORDS; __i++)                  \
  131                         (set).__bits[__i] = ~0U;                        \
  132         } while (0)
  133 
  134 #define SIGISMEMBER(set, signo)                                         \
  135         ((set).__bits[_SIG_WORD(signo)] & _SIG_BIT(signo))
  136 
  137 #define SIGISEMPTY(set)         (__sigisempty(&(set)))
  138 #define SIGNOTEMPTY(set)        (!__sigisempty(&(set)))
  139 
  140 #define SIGSETEQ(set1, set2)    (__sigseteq(&(set1), &(set2)))
  141 #define SIGSETNEQ(set1, set2)   (!__sigseteq(&(set1), &(set2)))
  142 
  143 #define SIGSETOR(set1, set2)                                            \
  144         do {                                                            \
  145                 int __i;                                                \
  146                 for (__i = 0; __i < _SIG_WORDS; __i++)                  \
  147                         (set1).__bits[__i] |= (set2).__bits[__i];       \
  148         } while (0)
  149 
  150 #define SIGSETAND(set1, set2)                                           \
  151         do {                                                            \
  152                 int __i;                                                \
  153                 for (__i = 0; __i < _SIG_WORDS; __i++)                  \
  154                         (set1).__bits[__i] &= (set2).__bits[__i];       \
  155         } while (0)
  156 
  157 #define SIGSETNAND(set1, set2)                                          \
  158         do {                                                            \
  159                 int __i;                                                \
  160                 for (__i = 0; __i < _SIG_WORDS; __i++)                  \
  161                         (set1).__bits[__i] &= ~(set2).__bits[__i];      \
  162         } while (0)
  163 
  164 #define SIGSETLO(set1, set2)    ((set1).__bits[0] = (set2).__bits[0])
  165 #define SIGSETOLD(set, oset)    ((set).__bits[0] = (oset))
  166 
  167 #define SIG_CANTMASK(set)                                               \
  168         SIGDELSET(set, SIGKILL), SIGDELSET(set, SIGSTOP)
  169 
  170 #define SIG_STOPSIGMASK(set)                                            \
  171         SIGDELSET(set, SIGSTOP), SIGDELSET(set, SIGTSTP),               \
  172         SIGDELSET(set, SIGTTIN), SIGDELSET(set, SIGTTOU)
  173 
  174 #define SIG_CONTSIGMASK(set)                                            \
  175         SIGDELSET(set, SIGCONT)
  176 
  177 #define sigcantmask     (sigmask(SIGKILL) | sigmask(SIGSTOP))
  178 
  179 #define SIG2OSIG(sig, osig)     (osig = (sig).__bits[0])
  180 #define OSIG2SIG(osig, sig)     SIGEMPTYSET(sig); (sig).__bits[0] = osig
  181 
  182 static __inline int
  183 __sigisempty(sigset_t *set)
  184 {
  185         int i;
  186 
  187         for (i = 0; i < _SIG_WORDS; i++) {
  188                 if (set->__bits[i])
  189                         return (0);
  190         }
  191         return (1);
  192 }
  193 
  194 static __inline int
  195 __sigseteq(sigset_t *set1, sigset_t *set2)
  196 {
  197         int i;
  198 
  199         for (i = 0; i < _SIG_WORDS; i++) {
  200                 if (set1->__bits[i] != set2->__bits[i])
  201                         return (0);
  202         }
  203         return (1);
  204 }
  205 
  206 #ifdef _KERNEL
  207 
  208 /*
  209  * Specifies the target of a signal.
  210  *      P - Doesn't matter which thread it gets delivered to.
  211  *      TD - Must be delivered to a specific thread.
  212  */
  213 typedef enum sigtarget_enum { SIGTARGET_P, SIGTARGET_TD } sigtarget_t;
  214 
  215 /* Return nonzero if process p has an unmasked pending signal. */
  216 #define SIGPENDING(td)                                                  \
  217         (!SIGISEMPTY((td)->td_siglist) &&                               \
  218             !sigsetmasked(&(td)->td_siglist, &(td)->td_sigmask))
  219 
  220 /*
  221  * Return the value of the pseudo-expression ((*set & ~*mask) != 0).  This
  222  * is an optimized version of SIGISEMPTY() on a temporary variable
  223  * containing SIGSETNAND(*set, *mask).
  224  */
  225 static __inline int
  226 sigsetmasked(sigset_t *set, sigset_t *mask)
  227 {
  228         int i;
  229 
  230         for (i = 0; i < _SIG_WORDS; i++) {
  231                 if (set->__bits[i] & ~mask->__bits[i])
  232                         return (0);
  233         }
  234         return (1);
  235 }
  236 
  237 struct pgrp;
  238 struct thread;
  239 struct proc;
  240 struct sigio;
  241 struct mtx;
  242 
  243 extern int sugid_coredump;      /* Sysctl variable kern.sugid_coredump */
  244 extern struct mtx       sigio_lock;
  245 
  246 /*
  247  * Lock the pointers for a sigio object in the underlying objects of
  248  * a file descriptor.
  249  */
  250 #define SIGIO_LOCK()    mtx_lock(&sigio_lock)
  251 #define SIGIO_TRYLOCK() mtx_trylock(&sigio_lock)
  252 #define SIGIO_UNLOCK()  mtx_unlock(&sigio_lock)
  253 #define SIGIO_LOCKED()  mtx_owned(&sigio_lock)
  254 #define SIGIO_ASSERT(type)      mtx_assert(&sigio_lock, type)
  255 
  256 /*
  257  * Machine-independent functions:
  258  */
  259 int     cursig(struct thread *td);
  260 void    execsigs(struct proc *p);
  261 void    gsignal(int pgid, int sig);
  262 void    killproc(struct proc *p, char *why);
  263 void    pgsigio(struct sigio **, int signum, int checkctty);
  264 void    pgsignal(struct pgrp *pgrp, int sig, int checkctty);
  265 void    postsig(int sig);
  266 void    psignal(struct proc *p, int sig);
  267 struct sigacts *sigacts_alloc(void);
  268 void    sigacts_copy(struct sigacts *dest, struct sigacts *src);
  269 void    sigacts_free(struct sigacts *ps);
  270 struct sigacts *sigacts_hold(struct sigacts *ps);
  271 int     sigacts_shared(struct sigacts *ps);
  272 void    sigexit(struct thread *td, int signum) __dead2;
  273 int     sig_ffs(sigset_t *set);
  274 void    siginit(struct proc *p);
  275 void    signotify(struct thread *td);
  276 void    tdsignal(struct thread *td, int sig, sigtarget_t target);
  277 void    trapsignal(struct thread *td, int sig, u_long code);
  278 void    ptracestop(struct thread *td, int sig);
  279 
  280 /*
  281  * Machine-dependent functions:
  282  */
  283 void    sendsig(sig_t action, int sig, sigset_t *retmask, u_long code);
  284 
  285 #endif /* _KERNEL */
  286 
  287 #endif /* !_SYS_SIGNALVAR_H_ */

Cache object: e3cd2f320808b74f9b38b0ea82f3be3e


[ 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.