Annotation of XNU/bsd/sys/signalvar.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
        !            23: /*
        !            24:  * Copyright (c) 1991, 1993
        !            25:  *     The Regents of the University of California.  All rights reserved.
        !            26:  *
        !            27:  * Redistribution and use in source and binary forms, with or without
        !            28:  * modification, are permitted provided that the following conditions
        !            29:  * are met:
        !            30:  * 1. Redistributions of source code must retain the above copyright
        !            31:  *    notice, this list of conditions and the following disclaimer.
        !            32:  * 2. Redistributions in binary form must reproduce the above copyright
        !            33:  *    notice, this list of conditions and the following disclaimer in the
        !            34:  *    documentation and/or other materials provided with the distribution.
        !            35:  * 3. All advertising materials mentioning features or use of this software
        !            36:  *    must display the following acknowledgement:
        !            37:  *     This product includes software developed by the University of
        !            38:  *     California, Berkeley and its contributors.
        !            39:  * 4. Neither the name of the University nor the names of its contributors
        !            40:  *    may be used to endorse or promote products derived from this software
        !            41:  *    without specific prior written permission.
        !            42:  *
        !            43:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            44:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            45:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            46:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            47:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            48:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            49:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            50:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            51:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            52:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            53:  * SUCH DAMAGE.
        !            54:  *
        !            55:  *     @(#)signalvar.h 8.3 (Berkeley) 1/4/94
        !            56:  */
        !            57: 
        !            58: #ifndef        _SYS_SIGNALVAR_H_               /* tmp for user.h */
        !            59: #define        _SYS_SIGNALVAR_H_
        !            60: 
        !            61: /*
        !            62:  * Kernel signal definitions and data structures,
        !            63:  * not exported to user programs.
        !            64:  */
        !            65: 
        !            66: /*
        !            67:  * Process signal actions and state, needed only within the process
        !            68:  * (not necessarily resident).
        !            69:  */
        !            70: struct sigacts {
        !            71:        sig_t   ps_sigact[NSIG];        /* disposition of signals */
        !            72:        sigset_t ps_catchmask[NSIG];    /* signals to be blocked */
        !            73:        sigset_t ps_sigonstack;         /* signals to take on sigstack */
        !            74:        sigset_t ps_sigintr;            /* signals that interrupt syscalls */
        !            75:        sigset_t ps_oldmask;            /* saved mask from before sigpause */
        !            76:        int     ps_flags;               /* signal flags, below */
        !            77:        struct  sigaltstack ps_sigstk;  /* sp & on stack state variable */
        !            78:        int     ps_sig;                 /* for core dump/debugger XXX */
        !            79:        int     ps_code;                /* for core dump/debugger XXX */
        !            80:        int     ps_addr;                /* for core dump/debugger XXX */
        !            81:        sigset_t ps_usertramp;          /* SunOS compat; libc sigtramp XXX */
        !            82: };
        !            83: 
        !            84: /* signal flags */
        !            85: #define        SAS_OLDMASK     0x01            /* need to restore mask before pause */
        !            86: #define        SAS_ALTSTACK    0x02            /* have alternate signal stack */
        !            87: 
        !            88: /* additional signal action values, used only temporarily/internally */
        !            89: #define        SIG_CATCH       (void (*)())2
        !            90: #define        SIG_HOLD        (void (*)())3
        !            91: 
        !            92: 
        !            93: #define pgsigio(pgid, sig, notused) \
        !            94:        { \
        !            95:        struct proc *p; \
        !            96:        if (pgid < 0) \
        !            97:                gsignal(-(pgid), sig);\
        !            98:        else if (pgid > 0 && (p = pfind(pgid)) != 0) \
        !            99:                psignal(p, sig); \
        !           100: }
        !           101: 
        !           102: 
        !           103: /*
        !           104:  * get signal action for process and signal; currently only for current process
        !           105:  */
        !           106: #define SIGACTION(p, sig)      (p->p_sigacts->ps_sigact[(sig)])
        !           107: 
        !           108: /*
        !           109:  * Determine signal that should be delivered to process p, the current
        !           110:  * process, 0 if none.  If there is a pending stop signal with default
        !           111:  * action, the process stops in issig().
        !           112:  */
        !           113: #define        CURSIG(p)                                                       \
        !           114:        (((p)->p_siglist == 0 ||                                        \
        !           115:            ((p)->p_flag & P_TRACED) == 0 &&                            \
        !           116:            ((p)->p_siglist & ~(p)->p_sigmask) == 0) ?                  \
        !           117:            0 : issignal(p))
        !           118: 
        !           119: #define        HAVE_SIGNALS(p) \
        !           120:         ((p)->p_siglist \
        !           121:          & ~((((p)->p_sigmask) \
        !           122:               | (((p)->p_flag & P_TRACED) ? 0 : (p)->p_sigignore)) \
        !           123:              & ~sigcantmask))
        !           124: 
        !           125: /*
        !           126:  *     Check for per-process and per thread signals.
        !           127:  */
        !           128: #define SHOULDissignal(p,uthreadp) \
        !           129:         (((p)->p_siglist | (uthreadp)->uu_sig) \
        !           130:          & ~((((p)->p_sigmask) \
        !           131:               | (((p)->p_flag & P_TRACED) ? 0 : (p)->p_sigignore)) \
        !           132:              & ~sigcantmask))
        !           133: 
        !           134: /*
        !           135:  *     Check for signals and per-thread signals.  
        !           136:  *  Use in trap() and syscall() before
        !           137:  *     exiting kernel.
        !           138:  */
        !           139: #define        CHECK_SIGNALS(p, thread, uthreadp)      \
        !           140:        (!thread_should_halt(thread)    \
        !           141:         && (SHOULDissignal(p,uthreadp)))
        !           142: 
        !           143:           
        !           144: /*
        !           145:  * Clear a pending signal from a process.
        !           146:  */
        !           147: #define        CLRSIG(p, sig)  { (p)->p_siglist &= ~sigmask(sig); }
        !           148: 
        !           149: /*
        !           150:  * Signal properties and actions.
        !           151:  * The array below categorizes the signals and their default actions
        !           152:  * according to the following properties:
        !           153:  */
        !           154: #define        SA_KILL         0x01            /* terminates process by default */
        !           155: #define        SA_CORE         0x02            /* ditto and coredumps */
        !           156: #define        SA_STOP         0x04            /* suspend process */
        !           157: #define        SA_TTYSTOP      0x08            /* ditto, from tty */
        !           158: #define        SA_IGNORE       0x10            /* ignore by default */
        !           159: #define        SA_CONT         0x20            /* continue if suspended */
        !           160: #define        SA_CANTMASK     0x40            /* non-maskable, catchable */
        !           161: 
        !           162: #ifdef SIGPROP
        !           163: int sigprop[NSIG + 1] = {
        !           164:        0,                      /* unused */
        !           165:        SA_KILL,                /* SIGHUP */
        !           166:        SA_KILL,                /* SIGINT */
        !           167:        SA_KILL|SA_CORE,        /* SIGQUIT */
        !           168:        SA_KILL|SA_CORE,        /* SIGILL */
        !           169:        SA_KILL|SA_CORE,        /* SIGTRAP */
        !           170:        SA_KILL|SA_CORE,        /* SIGABRT */
        !           171:        SA_KILL|SA_CORE,        /* SIGEMT */
        !           172:        SA_KILL|SA_CORE,        /* SIGFPE */
        !           173:        SA_KILL,                /* SIGKILL */
        !           174:        SA_KILL|SA_CORE,        /* SIGBUS */
        !           175:        SA_KILL|SA_CORE,        /* SIGSEGV */
        !           176:        SA_KILL|SA_CORE,        /* SIGSYS */
        !           177:        SA_KILL,                /* SIGPIPE */
        !           178:        SA_KILL,                /* SIGALRM */
        !           179:        SA_KILL,                /* SIGTERM */
        !           180:        SA_IGNORE,              /* SIGURG */
        !           181:        SA_STOP,                /* SIGSTOP */
        !           182:        SA_STOP|SA_TTYSTOP,     /* SIGTSTP */
        !           183:        SA_IGNORE|SA_CONT,      /* SIGCONT */
        !           184:        SA_IGNORE,              /* SIGCHLD */
        !           185:        SA_STOP|SA_TTYSTOP,     /* SIGTTIN */
        !           186:        SA_STOP|SA_TTYSTOP,     /* SIGTTOU */
        !           187:        SA_IGNORE,              /* SIGIO */
        !           188:        SA_KILL,                /* SIGXCPU */
        !           189:        SA_KILL,                /* SIGXFSZ */
        !           190:        SA_KILL,                /* SIGVTALRM */
        !           191:        SA_KILL,                /* SIGPROF */
        !           192:        SA_IGNORE,              /* SIGWINCH  */
        !           193:        SA_IGNORE,              /* SIGINFO */
        !           194:        SA_KILL,                /* SIGUSR1 */
        !           195:        SA_KILL,                /* SIGUSR2 */
        !           196: };
        !           197: 
        !           198: #define        contsigmask     (sigmask(SIGCONT))
        !           199: #define        stopsigmask     (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
        !           200:                            sigmask(SIGTTIN) | sigmask(SIGTTOU))
        !           201: 
        !           202: #endif /* SIGPROP */
        !           203: 
        !           204: #define        sigcantmask     (sigmask(SIGKILL) | sigmask(SIGSTOP))
        !           205: 
        !           206: #ifdef KERNEL
        !           207: /*
        !           208:  * Machine-independent functions:
        !           209:  */
        !           210: int    coredump __P((struct proc *p));
        !           211: void   execsigs __P((struct proc *p));
        !           212: void   gsignal __P((int pgid, int sig));
        !           213: int    issig __P((struct proc *p));
        !           214: void   pgsignal __P((struct pgrp *pgrp, int sig, int checkctty));
        !           215: void   postsig __P((int sig));
        !           216: void   psignal __P((struct proc *p, int sig));
        !           217: void   siginit __P((struct proc *p));
        !           218: void   trapsignal __P((struct proc *p, int sig, unsigned code));
        !           219: 
        !           220: /*
        !           221:  * Machine-dependent functions:
        !           222:  */
        !           223: void   sendsig __P((struct proc *, sig_t action, int sig, int returnmask, u_long code));
        !           224: #endif /* KERNEL */
        !           225: #endif /* !_SYS_SIGNALVAR_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.