home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / signalvar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-09  |  7.1 KB  |  215 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    signalvar.h,v $
  29.  * Revision 2.2  92/07/08  16:20:42  mrt
  30.  *     Corrected declaration of sendsig to have 6 parameters.
  31.  *     [92/06/26            mrt]
  32.  * 
  33.  * Revision 2.1  92/04/21  17:15:41  rwd
  34.  * BSDSS
  35.  * 
  36.  *
  37.  */
  38.  
  39. /*
  40.  * Copyright (c) 1991 Regents of the University of California.
  41.  * All rights reserved.
  42.  *
  43.  * Redistribution and use in source and binary forms, with or without
  44.  * modification, are permitted provided that the following conditions
  45.  * are met:
  46.  * 1. Redistributions of source code must retain the above copyright
  47.  *    notice, this list of conditions and the following disclaimer.
  48.  * 2. Redistributions in binary form must reproduce the above copyright
  49.  *    notice, this list of conditions and the following disclaimer in the
  50.  *    documentation and/or other materials provided with the distribution.
  51.  * 3. All advertising materials mentioning features or use of this software
  52.  *    must display the following acknowledgement:
  53.  *    This product includes software developed by the University of
  54.  *    California, Berkeley and its contributors.
  55.  * 4. Neither the name of the University nor the names of its contributors
  56.  *    may be used to endorse or promote products derived from this software
  57.  *    without specific prior written permission.
  58.  *
  59.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  60.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  61.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  62.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  63.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  64.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  65.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  66.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  67.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  68.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  69.  * SUCH DAMAGE.
  70.  *
  71.  *    @(#)signalvar.h    7.1 (Berkeley) 5/9/91
  72.  */
  73.  
  74. #ifndef    _SIGNALVAR_H_        /* tmp for user.h */
  75. #define    _SIGNALVAR_H_
  76.  
  77.  
  78. /*
  79.  * Kernel signal definitions and data structures,
  80.  * not exported to user programs.
  81.  */
  82.  
  83. /*
  84.  * Process signal actions and state, needed only within the process
  85.  * (not necessarily resident).
  86.  */
  87. struct    sigacts {
  88.     sig_t    ps_sigact[NSIG];    /* disposition of signals */
  89.     sigset_t ps_catchmask[NSIG];    /* signals to be blocked */
  90.     sigset_t ps_sigonstack;        /* signals to take on sigstack */
  91.     sigset_t ps_sigintr;        /* signals that interrupt syscalls */
  92.     sigset_t ps_oldmask;        /* saved mask from before sigpause */
  93.     int    ps_flags;        /* signal flags, below */
  94.     struct    sigstack ps_sigstack;    /* sp & on stack state variable */
  95.     int    ps_sig;            /* for core dump/debugger XXX */
  96.     int    ps_code;        /* for core dump/debugger XXX */
  97. };
  98.  
  99. #define    ps_onstack    ps_sigstack.ss_onstack
  100. #define    ps_sigsp    ps_sigstack.ss_sp
  101.  
  102. /* signal flags */
  103. #define    SA_OLDMASK    0x01        /* need to restore mask before pause */
  104.  
  105. /* additional signal action values, used only temporarily/internally */
  106. #define    SIG_CATCH    (void (*)())2
  107. #define    SIG_HOLD    (void (*)())3
  108.  
  109. /*
  110.  * get signal action for process and signal; currently only for current process
  111.  */
  112. #define SIGACTION(p, sig)    (p->p_sigacts->ps_sigact[(sig)])
  113.  
  114. /*
  115.  * Determine signal that should be delivered to process p, the current process,
  116.  * 0 if none.  If there is a pending stop signal with default action,
  117.  * the process stops in issig().
  118.  */
  119. #define    CURSIG(p) \
  120.     (((p)->p_sig == 0 || \
  121.         ((p)->p_flag&STRC) == 0 && ((p)->p_sig &~ (p)->p_sigmask) == 0) ? \
  122.         0 : issig(p))
  123.  
  124. #define    HAVE_SIGNALS(p)    \
  125.     ( (p)->p_sig & ~ \
  126.         ( (p)->p_sigmask \
  127.           | ( ((p)->p_flag&STRC) ? 0 : (p)->p_sigignore) \
  128.         ) \
  129.     )
  130.  
  131. #define    EXITING(p)    (((p)->p_flag & SWEXIT) != 0)
  132. /*
  133.  * Clear a pending signal from a process.
  134.  */
  135. #define    CLRSIG(p, sig)    { (p)->p_sig &= ~sigmask(sig); }
  136.  
  137. /*
  138.  * Signal properties and actions.
  139.  * The array below categorizes the signals and their default actions
  140.  * according to the following properties:
  141.  */
  142. #define    SA_KILL        0x01        /* terminates process by default */
  143. #define    SA_CORE        0x02        /* ditto and coredumps */
  144. #define    SA_STOP        0x04        /* suspend process */
  145. #define    SA_TTYSTOP    (0x08|SA_STOP)    /* ditto, from tty */
  146. #define    SA_IGNORE    0x10        /* ignore by default */
  147. #define    SA_CONT        0x20        /* continue if suspended */
  148. #define    SA_CANTMASK    0x40        /* non-maskable, catchable */
  149.  
  150. #ifdef    SIGPROP
  151. int sigprop[NSIG + 1] = {
  152.     0,            /* unused */
  153.     SA_KILL,        /* SIGHUP */
  154.     SA_KILL,        /* SIGINT */
  155.     SA_KILL|SA_CORE,    /* SIGQUIT */
  156.     SA_KILL|SA_CORE,    /* SIGILL */
  157.     SA_KILL|SA_CORE,    /* SIGTRAP */
  158.     SA_KILL|SA_CORE,    /* SIGABRT */
  159.     SA_KILL|SA_CORE,    /* SIGEMT */
  160.     SA_KILL|SA_CORE,    /* SIGFPE */
  161.     SA_KILL,        /* SIGKILL */
  162.     SA_KILL|SA_CORE,    /* SIGBUS */
  163.     SA_KILL|SA_CORE,    /* SIGSEGV */
  164.     SA_KILL|SA_CORE,    /* SIGSYS */
  165.     SA_KILL,        /* SIGPIPE */
  166.     SA_KILL,        /* SIGALRM */
  167.     SA_KILL,        /* SIGTERM */
  168.     SA_IGNORE,        /* SIGURG */
  169.     SA_STOP,        /* SIGSTOP */
  170.     SA_TTYSTOP,        /* SIGTSTP */
  171.     SA_IGNORE|SA_CONT,    /* SIGCONT */
  172.     SA_IGNORE,        /* SIGCHLD */
  173.     SA_TTYSTOP,        /* SIGTTIN */
  174.     SA_TTYSTOP,        /* SIGTTOU */
  175.     SA_IGNORE,        /* SIGIO */
  176.     SA_KILL,        /* SIGXCPU */
  177.     SA_KILL,        /* SIGXFSZ */
  178.     SA_KILL,        /* SIGVTALRM */
  179.     SA_KILL,        /* SIGPROF */
  180.     SA_IGNORE,        /* SIGWINCH  */
  181.     SA_IGNORE,        /* SIGINFO */
  182.     SA_KILL,        /* SIGUSR1 */
  183.     SA_KILL,        /* SIGUSR2 */
  184. };
  185.  
  186. #define    stopsigmask    (sigmask(SIGSTOP)|sigmask(SIGTSTP)|\
  187.              sigmask(SIGTTIN)|sigmask(SIGTTOU))
  188. #define    contsigmask    (sigmask(SIGCONT))
  189.  
  190. #endif /* SIGPROP */
  191.  
  192. #define    sigcantmask    (sigmask(SIGKILL)|sigmask(SIGSTOP))
  193.  
  194. #ifdef KERNEL
  195. #include <uxkern/import_mach.h>
  196. /*
  197.  * Machine-independent functions:
  198.  */
  199. void    siginit __P((struct proc *p));
  200. void    execsigs __P((struct proc *p));
  201. void    gsignal __P((int pgid, int sig));
  202. void    pgsignal __P((struct pgrp *pgrp, int sig, int checkctty));
  203. void    trapsignal __P((struct proc *p, int sig, unsigned code));
  204. void    psignal __P((struct proc *p, int sig));
  205. int    issig __P((struct proc *p));
  206. void    psig __P((int sig));
  207. int    coredump __P((struct proc *p));
  208.  
  209. /*
  210.  * Machine-dependent functions:
  211.  */
  212. void    sendsig __P((struct proc *p, thread_t thread, sig_t action, int sig, int code, int returnmask));
  213. #endif    /* KERNEL */
  214. #endif    /* !_SIGNALVAR_H_ */
  215.