[BACK]Return to signalvar.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / sys

Annotation of src/sys/sys/signalvar.h, Revision 1.78.2.1

1.78.2.1! jruoho      1: /*     $NetBSD: signalvar.h,v 1.81 2011/05/28 15:33:41 christos Exp $  */
1.11      cgd         2:
1.1       cgd         3: /*
1.8       cgd         4:  * Copyright (c) 1991, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
1.1       cgd         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.
1.41      agc        15:  * 3. Neither the name of the University nor the names of its contributors
1.1       cgd        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:  *
1.18      fvdl       31:  *     @(#)signalvar.h 8.6 (Berkeley) 2/19/95
1.1       cgd        32:  */
                     33:
1.78      rmind      34: #ifndef        _SYS_SIGNALVAR_H_
1.8       cgd        35: #define        _SYS_SIGNALVAR_H_
1.1       cgd        36:
1.49      thorpej    37: #include <sys/siginfo.h>
1.44      christos   38: #include <sys/queue.h>
1.69      ad         39: #include <sys/mutex.h>
1.49      thorpej    40:
1.1       cgd        41: /*
                     42:  * Kernel signal definitions and data structures,
                     43:  * not exported to user programs.
                     44:  */
                     45:
                     46: /*
1.69      ad         47:  * Queue of signals.
                     48:  */
                     49: typedef CIRCLEQ_HEAD(ksiginfoq, ksiginfo) ksiginfoq_t;
                     50:
                     51: /*
                     52:  * Process signal actions, possibly shared between processes.
1.1       cgd        53:  */
1.27      jdolecek   54: struct sigacts {
1.33      thorpej    55:        struct sigact_sigdesc {
                     56:                struct sigaction sd_sigact;
1.69      ad         57:                const void      *sd_tramp;
                     58:                int             sd_vers;
1.33      thorpej    59:        } sa_sigdesc[NSIG];             /* disposition of signals */
1.27      jdolecek   60:
1.69      ad         61:        int             sa_refcnt;      /* reference count */
                     62:        kmutex_t        sa_mutex;       /* lock on sa_refcnt */
1.27      jdolecek   63: };
                     64:
                     65: /*
1.69      ad         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: /*
1.27      jdolecek   74:  * Process signal state.
                     75:  */
1.43      christos   76: struct sigctx {
1.69      ad         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. */
1.1       cgd        83: };
                     84:
1.69      ad         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;
1.1       cgd        93:
                     94: /* additional signal action values, used only temporarily/internally */
1.54      perry      95: #define        SIG_CATCH       (void (*)(int))2
1.1       cgd        96:
                     97: /*
                     98:  * get signal action for process and signal; currently only for current process
                     99:  */
1.33      thorpej   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)
1.28      thorpej   102:
                    103: /*
1.1       cgd       104:  * Signal properties and actions.
                    105:  * The array below categorizes the signals and their default actions
                    106:  * according to the following properties:
                    107:  */
1.69      ad        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 */
1.1       cgd       118:
1.21      drochner  119: #ifdef _KERNEL
                    120:
1.61      cube      121: #include <sys/systm.h>                 /* for copyin_t/copyout_t */
                    122:
1.78.2.1! jruoho    123: extern sigset_t contsigmask, sigcantmask;
1.30      mrg       124:
                    125: struct vnode;
1.1       cgd       126:
                    127: /*
                    128:  * Machine-independent functions:
                    129:  */
1.55      matt      130: int    coredump_netbsd(struct lwp *, void *);
1.54      perry     131: void   execsigs(struct proc *);
                    132: int    issignal(struct lwp *);
                    133: void   pgsignal(struct pgrp *, int, int);
                    134: void   kpgsignal(struct pgrp *, struct ksiginfo *, void *, int);
                    135: void   postsig(int);
1.67      yamt      136: void   psignal(struct proc *, int);
1.68      yamt      137: void   kpsignal(struct proc *, struct ksiginfo *, void *);
1.69      ad        138: void   child_psignal(struct proc *, int);
1.54      perry     139: void   siginit(struct proc *);
1.69      ad        140: void   trapsignal(struct lwp *, struct ksiginfo *);
1.54      perry     141: void   sigexit(struct lwp *, int);
                    142: void   killproc(struct proc *, const char *);
                    143: void   setsigvec(struct proc *, int, struct sigaction *);
1.66      ad        144: int    killpg1(struct lwp *, struct ksiginfo *, int, int);
1.69      ad        145: void   proc_unstop(struct proc *p);
1.54      perry     146:
1.69      ad        147: int    sigaction1(struct lwp *, int, const struct sigaction *,
1.54      perry     148:            struct sigaction *, const void *, int);
1.69      ad        149: int    sigprocmask1(struct lwp *, int, const sigset_t *, sigset_t *);
                    150: void   sigpending1(struct lwp *, sigset_t *);
1.78.2.1! jruoho    151: void   sigsuspendsetup(struct lwp *, const sigset_t *);
        !           152: void   sigsuspendteardown(struct lwp *);
1.69      ad        153: int    sigsuspend1(struct lwp *, const sigset_t *);
                    154: int    sigaltstack1(struct lwp *, const struct sigaltstack *,
1.54      perry     155:            struct sigaltstack *);
1.69      ad        156: int    sigismasked(struct lwp *, int);
                    157:
1.73      yamt      158: int    sigget(sigpend_t *, ksiginfo_t *, int, const sigset_t *);
                    159: void   sigclear(sigpend_t *, const sigset_t *, ksiginfoq_t *);
                    160: void   sigclearall(struct proc *, const sigset_t *, ksiginfoq_t *);
1.69      ad        161:
                    162: void   kpsignal2(struct proc *, ksiginfo_t *);
1.54      perry     163:
                    164: void   signal_init(void);
                    165:
1.69      ad        166: struct sigacts *sigactsinit(struct proc *, int);
1.54      perry     167: void   sigactsunshare(struct proc *);
                    168: void   sigactsfree(struct sigacts *);
1.19      mycroft   169:
1.54      perry     170: void   kpsendsig(struct lwp *, const struct ksiginfo *, const sigset_t *);
1.69      ad        171: void   sendsig_reset(struct lwp *, int);
1.74      ad        172: void   sendsig(const struct ksiginfo *, const sigset_t *);
1.69      ad        173:
1.59      chs       174: siginfo_t *siginfo_alloc(int);
                    175: void   siginfo_free(void *);
1.37      thorpej   176:
1.69      ad        177: ksiginfo_t     *ksiginfo_alloc(struct proc *, ksiginfo_t *, int);
                    178: void   ksiginfo_free(ksiginfo_t *);
                    179: void   ksiginfo_queue_drain0(ksiginfoq_t *);
                    180:
1.75      christos  181: struct sys_____sigtimedwait50_args;
1.76      pooka     182: int    sigtimedwait1(struct lwp *, const struct sys_____sigtimedwait50_args *,
                    183:                      register_t *, copyout_t, copyin_t, copyout_t);
1.57      cube      184:
1.69      ad        185: void   signotify(struct lwp *);
                    186: int    sigispending(struct lwp *, int);
                    187:
1.1       cgd       188: /*
                    189:  * Machine-dependent functions:
                    190:  */
1.74      ad        191: void   sendsig_sigcontext(const struct ksiginfo *, const sigset_t *);
                    192: void   sendsig_siginfo(const struct ksiginfo *, const sigset_t *);
1.20      thorpej   193:
1.69      ad        194: extern struct pool ksiginfo_pool;
                    195:
                    196: /*
1.74      ad        197:  * Modularity / compatibility.
                    198:  */
                    199: extern void    (*sendsig_sigcontext_vec)(const struct ksiginfo *,
                    200:                                          const sigset_t *);
                    201: extern int     (*coredump_vec)(struct lwp *, const char *);
                    202:
                    203: /*
1.69      ad        204:  * firstsig:
                    205:  *
                    206:  *     Return the first signal in a signal set.
                    207:  */
                    208: static inline int
                    209: firstsig(const sigset_t *ss)
                    210: {
                    211:        int sig;
                    212:
                    213:        sig = ffs(ss->__bits[0]);
                    214:        if (sig != 0)
                    215:                return (sig);
                    216: #if NSIG > 33
                    217:        sig = ffs(ss->__bits[1]);
                    218:        if (sig != 0)
                    219:                return (sig + 32);
                    220: #endif
                    221: #if NSIG > 65
                    222:        sig = ffs(ss->__bits[2]);
                    223:        if (sig != 0)
                    224:                return (sig + 64);
                    225: #endif
                    226: #if NSIG > 97
                    227:        sig = ffs(ss->__bits[3]);
                    228:        if (sig != 0)
                    229:                return (sig + 96);
                    230: #endif
                    231:        return (0);
                    232: }
                    233:
                    234: static inline void
                    235: ksiginfo_queue_init(ksiginfoq_t *kq)
                    236: {
                    237:        CIRCLEQ_INIT(kq);
                    238: }
                    239:
                    240: static inline void
                    241: ksiginfo_queue_drain(ksiginfoq_t *kq)
                    242: {
                    243:        if (!CIRCLEQ_EMPTY(kq))
                    244:                ksiginfo_queue_drain0(kq);
                    245: }
                    246:
1.13      jtc       247: #endif /* _KERNEL */
1.35      matt      248:
                    249: #ifdef _KERNEL
                    250: #ifdef SIGPROP
                    251: const int sigprop[NSIG] = {
1.69      ad        252:        0,                                      /* 0 unused */
                    253:        SA_KILL,                                /* 1 SIGHUP */
                    254:        SA_KILL,                                /* 2 SIGINT */
                    255:        SA_KILL|SA_CORE,                        /* 3 SIGQUIT */
                    256:        SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP,    /* 4 SIGILL */
                    257:        SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP,    /* 5 SIGTRAP */
                    258:        SA_KILL|SA_CORE,                        /* 6 SIGABRT */
                    259:        SA_KILL|SA_CORE|SA_TOLWP,               /* 7 SIGEMT */
                    260:        SA_KILL|SA_CORE|SA_TOLWP,               /* 8 SIGFPE */
                    261:        SA_KILL|SA_CANTMASK|SA_TOALL,           /* 9 SIGKILL */
                    262:        SA_KILL|SA_CORE|SA_TOLWP,               /* 10 SIGBUS */
                    263:        SA_KILL|SA_CORE|SA_TOLWP,               /* 11 SIGSEGV */
                    264:        SA_KILL|SA_CORE|SA_TOLWP,               /* 12 SIGSYS */
                    265:        SA_KILL,                                /* 13 SIGPIPE */
                    266:        SA_KILL,                                /* 14 SIGALRM */
                    267:        SA_KILL,                                /* 15 SIGTERM */
                    268:        SA_IGNORE,                              /* 16 SIGURG */
                    269:        SA_STOP|SA_CANTMASK|SA_TOALL,           /* 17 SIGSTOP */
                    270:        SA_STOP|SA_TTYSTOP|SA_TOALL,            /* 18 SIGTSTP */
                    271:        SA_IGNORE|SA_CONT|SA_TOALL,             /* 19 SIGCONT */
                    272:        SA_IGNORE,                              /* 20 SIGCHLD */
                    273:        SA_STOP|SA_TTYSTOP|SA_TOALL,            /* 21 SIGTTIN */
                    274:        SA_STOP|SA_TTYSTOP|SA_TOALL,            /* 22 SIGTTOU */
                    275:        SA_IGNORE,                              /* 23 SIGIO */
                    276:        SA_KILL,                                /* 24 SIGXCPU */
                    277:        SA_KILL,                                /* 25 SIGXFSZ */
                    278:        SA_KILL,                                /* 26 SIGVTALRM */
                    279:        SA_KILL,                                /* 27 SIGPROF */
                    280:        SA_IGNORE,                              /* 28 SIGWINCH  */
                    281:        SA_IGNORE,                              /* 29 SIGINFO */
                    282:        SA_KILL,                                /* 30 SIGUSR1 */
                    283:        SA_KILL,                                /* 31 SIGUSR2 */
                    284:        SA_IGNORE|SA_NORESET,                   /* 32 SIGPWR */
                    285:        SA_KILL,                                /* 33 SIGRTMIN + 0 */
                    286:        SA_KILL,                                /* 34 SIGRTMIN + 1 */
                    287:        SA_KILL,                                /* 35 SIGRTMIN + 2 */
                    288:        SA_KILL,                                /* 36 SIGRTMIN + 3 */
                    289:        SA_KILL,                                /* 37 SIGRTMIN + 4 */
                    290:        SA_KILL,                                /* 38 SIGRTMIN + 5 */
                    291:        SA_KILL,                                /* 39 SIGRTMIN + 6 */
                    292:        SA_KILL,                                /* 40 SIGRTMIN + 7 */
                    293:        SA_KILL,                                /* 41 SIGRTMIN + 8 */
                    294:        SA_KILL,                                /* 42 SIGRTMIN + 9 */
                    295:        SA_KILL,                                /* 43 SIGRTMIN + 10 */
                    296:        SA_KILL,                                /* 44 SIGRTMIN + 11 */
                    297:        SA_KILL,                                /* 45 SIGRTMIN + 12 */
                    298:        SA_KILL,                                /* 46 SIGRTMIN + 13 */
                    299:        SA_KILL,                                /* 47 SIGRTMIN + 14 */
                    300:        SA_KILL,                                /* 48 SIGRTMIN + 15 */
                    301:        SA_KILL,                                /* 49 SIGRTMIN + 16 */
                    302:        SA_KILL,                                /* 50 SIGRTMIN + 17 */
                    303:        SA_KILL,                                /* 51 SIGRTMIN + 18 */
                    304:        SA_KILL,                                /* 52 SIGRTMIN + 19 */
                    305:        SA_KILL,                                /* 53 SIGRTMIN + 20 */
                    306:        SA_KILL,                                /* 54 SIGRTMIN + 21 */
                    307:        SA_KILL,                                /* 55 SIGRTMIN + 22 */
                    308:        SA_KILL,                                /* 56 SIGRTMIN + 23 */
                    309:        SA_KILL,                                /* 57 SIGRTMIN + 24 */
                    310:        SA_KILL,                                /* 58 SIGRTMIN + 25 */
                    311:        SA_KILL,                                /* 59 SIGRTMIN + 26 */
                    312:        SA_KILL,                                /* 60 SIGRTMIN + 27 */
                    313:        SA_KILL,                                /* 61 SIGRTMIN + 28 */
                    314:        SA_KILL,                                /* 62 SIGRTMIN + 29 */
                    315:        SA_KILL,                                /* 63 SIGRTMIN + 30 */
1.35      matt      316: };
                    317: #undef SIGPROP
                    318: #else
                    319: extern const int sigprop[NSIG];
                    320: #endif /* SIGPROP */
                    321: #endif /* _KERNEL */
1.56      christos  322: #endif /* !_SYS_SIGNALVAR_H_ */

CVSweb <webmaster@jp.NetBSD.org>