home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / sys / signal.h < prev    next >
C/C++ Source or Header  |  1993-10-19  |  8KB  |  282 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7. /*
  8.  * HISTORY
  9.  *  7-Jan-93  Mac Gillon (mgillon) at NeXT
  10.  *    Integrated POSIX changes
  11.  *
  12.  * 21-May-89  Avadis Tevanian, Jr. (avie) at NeXT, Inc.
  13.  *    Purged all crud that had accumulated in this file.  Machine specific
  14.  *    definitions now go in <machine/signal.h> (including sigcontext).
  15.  */
  16.  
  17. /*
  18.  * Copyright (c) 1982, 1986 Regents of the University of California.
  19.  * All rights reserved.  The Berkeley software License Agreement
  20.  * specifies the terms and conditions for redistribution.
  21.  *
  22.  *    @(#)signal.h    7.1 (Berkeley) 6/4/86
  23.  */
  24.  
  25. #ifndef _SYS_SIGNAL_H
  26. #define _SYS_SIGNAL_H
  27.  
  28. #if !defined(KERNEL) && defined(_POSIX_SOURCE)
  29. #include <standards.h>
  30. #endif
  31.  
  32. #ifdef _NEXT_SOURCE
  33.     #import <machine/signal.h>
  34.     #define NSIG    32
  35. #endif
  36.  
  37. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  38.     #define    SIGHUP    1    /* hangup */
  39.     #define    SIGINT    2    /* interrupt */
  40.     #define    SIGQUIT    3    /* quit */
  41.     #define    SIGILL    4    /* illegal instruction (not */
  42.                     /* reset when  caught) */
  43. #endif /* _POSIX_SOURCE || _NEXT_SOURCE */
  44.  
  45. #ifdef _NEXT_SOURCE
  46. /* CHME, CHMS, CHMU are not yet given back to users 
  47. * reasonably
  48. */
  49.     #define    SIGTRAP    5     /* trace trap (not reset */
  50. #endif /* _NEXT_SOURCE */
  51.  
  52. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  53.     #define    SIGABRT    6    /* IOT instruction */
  54. #endif /* _POSIX_SOURCE || _NEXT_SOURCE */
  55.  
  56. #ifdef _NEXT_SOURCE
  57.     #define    SIGIOT    SIGABRT    /* compatibility */
  58.     #define    SIGEMT    7    /* EMT instruction */
  59. #endif /* _NEXT_SOURCE */
  60.  
  61. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  62.     #define    SIGFPE    8    /* floating point exception */
  63.     #define    SIGKILL    9    /* kill (cannot be caught */
  64.                     /* or ignored) */
  65. #endif /* _POSIX_SOURCE || _NEXT_SOURCE */
  66.  
  67. #ifdef _NEXT_SOURCE
  68.     #define    SIGBUS    10    /* bus error */
  69. #endif /* _NEXT_SOURCE */
  70.  
  71. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  72.     #define    SIGSEGV    11    /* segmentation violation */
  73. #endif /* _POSIX_SOURCE || _NEXT_SOURCE */
  74.  
  75. #ifdef _NEXT_SOURCE
  76.     #define    SIGSYS    12    /* bad argument to system */
  77.                 /* call */
  78. #endif /* _NEXT_SOURCE */
  79.  
  80. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  81.     #define    SIGPIPE    13    /* write on a pipe with no */
  82.                 /* one to read  it */
  83.     #define    SIGALRM    14    /* alarm clock */
  84.     #define    SIGTERM    15    /* software termination */
  85.                 /* signal from kill */
  86. #endif /* _POSIX_SOURCE || _NEXT_SOURCE */
  87.  
  88. #ifdef _NEXT_SOURCE
  89.     #define    SIGURG    16    /* urgent condition on IO */
  90.                 /* channel */
  91. #endif /* _NEXT_SOURCE */
  92.  
  93. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  94.     #define    SIGSTOP    17    /* sendable stop signal */
  95.                 /* not from tty */
  96.     #define    SIGTSTP    18    /* stop signal from tty */
  97.     #define    SIGCONT    19    /* continue a stopped process */
  98.     #define    SIGCHLD    20    /* to parent on child stop */
  99.                 /* or exit */
  100. #endif /* _POSIX_SOURCE || _NEXT_SOURCE */
  101.  
  102. #ifdef _NEXT_SOURCE
  103.     #define    SIGCLD    SIGCHLD    /* compatibility */
  104. #endif /* _NEXT_SOURCE */
  105.  
  106. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  107.     #define    SIGTTIN    21    /* to readers pgrp upon */
  108.                 /* background tty read */
  109.     #define    SIGTTOU    22    /* like TTIN for output */
  110.                  /* if (tp->t_local<OSTOP) */
  111. #endif /* _POSIX_SOURCE || _NEXT_SOURCE */
  112.  
  113. #ifdef _NEXT_SOURCE
  114.     #define    SIGIO    23    /* input/output possible */
  115.                 /* signal */
  116.     #define    SIGXCPU    24    /* exceeded CPU time limit */
  117.     #define    SIGXFSZ    25    /* exceeded file size limit */
  118.     #define    SIGVTALRM 26    /* virtual time alarm */
  119.     #define    SIGPROF    27    /* profiling time alarm */
  120.     #define SIGWINCH 28    /* window size changes */
  121.     /* SUN_LOCK*/
  122.     #define    SIGLOST 29    /* resource lost 
  123.                  * (eg, record-lock lost) */
  124.         /* SUN_LOCK*/
  125. #endif /* _NEXT_SOURCE */
  126.  
  127. #define SIGUSR1 30    /* user defined signal 1 */
  128. #define SIGUSR2 31    /* user defined signal 2 */
  129.  
  130. #if    !defined(__STDC__) && !defined(KERNEL)
  131. int    (*signal())();
  132. #endif    !defined(__STDC__) && !defined(KERNEL)
  133.  
  134. #ifdef _NEXT_SOURCE
  135.     #if    !defined(__STDC__) && !defined(KERNEL)
  136.         int    (*signal())();
  137.     #endif
  138.  
  139.     /*
  140.      * Signal vector "template" used in sigvec call.
  141.      */
  142.     #ifndef    ASSEMBLER
  143.         struct    sigvec {
  144.             void    (*sv_handler)();  /* signal handler */
  145.             int    sv_mask; /* signal mask to apply */
  146.             int    sv_flags; /* see signal options below */
  147.             };
  148.     #endif    /* ASSEMBLER */
  149.     #define SV_ONSTACK    0x0001    /* take signal on signal */
  150.                     /* stack */
  151.     #define SV_INTERRUPT    0x0002  /* do not restart system */
  152.                     /* on signal return */
  153.     #define sv_onstack sv_flags    /* isn't compatibility */
  154.                         /* wonderful! */
  155.     /*
  156.      * Structure used in sigstack call.
  157.     */
  158.     #ifndef    ASSEMBLER
  159.         struct    sigstack {
  160.             char    *ss_sp;        /* signal stack pointer */
  161.             int    ss_onstack; /* current status */
  162.         };
  163.     #endif    ASSEMBLER
  164. #endif /* _NEXT_SOURCE */
  165.  
  166. #ifdef __STRICT_BSD__
  167.     #define    BADSIG        (int (*)())-1
  168.     #define    SIG_DFL        (int (*)())0
  169.     #define    SIG_IGN        (int (*)())1
  170.  
  171.     #ifdef KERNEL
  172.         #define    SIG_CATCH    (int (*)())2
  173.         #define    SIG_HOLD    (int (*)())3
  174.     #endif
  175.  
  176. #else /* __STRICT_BSD__ */
  177.  
  178.     #ifdef _NEXT_SOURCE 
  179.         #define    BADSIG        (void (*)())-1
  180.     #endif /* _NEXT_SOURCE */
  181.  
  182.     #if defined(_NEXT_SOURCE) || defined(_POSIX_SOURCE)
  183.         #define    SIG_DFL        (void (*)())0
  184.         #define    SIG_IGN        (void (*)())1
  185.     #endif /* _NEXT_SOURCE || _POSIX_SOURCE  */
  186.  
  187.  
  188.     #ifdef KERNEL
  189.         #define    SIG_CATCH    (void (*)())2
  190.         #define    SIG_HOLD    (void (*)())3
  191.     #endif
  192.  
  193. #endif /* __STRICT_BSD__ */
  194.  
  195. #ifdef _NEXT_SOURCE
  196.     #if    defined(__STDC__) && !defined(KERNEL)
  197.         /* man(2) declarations */
  198.         extern int sigblock(int);
  199.         extern int sigpause(int);
  200.         extern int sigreturn(struct sigcontext *);
  201.         extern int sigsetmask(int);
  202.         extern int sigstack(struct sigstack *, \
  203.                     struct sigstack *);
  204.         extern int sigvec(int, struct sigvec *, \
  205.                     struct sigvec *);
  206.         /* man(3) declarations */
  207.         extern int siginterrupt(int, int);
  208.         #ifdef __STRICT_BSD__
  209.             extern int (*signal(int, int (*)()))();
  210.         #else
  211.             extern void (*signal(int, \
  212.                 void (*)(int)))(int);
  213.         #endif
  214.     #endif    /* __STDC__ && KERNEL */
  215.  
  216.     /*
  217.      * Macro for converting signal number to a mask suitable for
  218.      * sigblock().
  219.      */
  220.     #define sigmask(m)    (1 << ((m)-1))
  221.  
  222.     #if    KERNEL
  223.         /*
  224.          *    signals delivered on a per-thread basis.
  225.          */
  226.         #define threadmask (sigmask(SIGILL)|sigmask(SIGTRAP)|\
  227.                     sigmask(SIGIOT)|sigmask(SIGEMT)|\
  228.                     sigmask(SIGFPE)|sigmask(SIGBUS)|\
  229.                     sigmask(SIGSEGV)|sigmask(SIGSYS)|\
  230.                     sigmask(SIGPIPE))
  231.     #endif    KERNEL
  232. #endif /* _NEXT_SOURCE */
  233.  
  234. #ifdef _POSIX_SOURCE        /* Additional entries required by */
  235.                 /* POSIX               */
  236.  
  237.     #include <sys/types.h>    /* for pid_t */
  238.  
  239.     typedef int sigset_t; 
  240.  
  241.     struct sigaction {
  242.         void        (*sa_handler)();
  243.         sigset_t    sa_mask;
  244.         int        sa_flags;
  245.     };
  246.  
  247.     #define SIG_BLOCK    00
  248.     #define SIG_UNBLOCK    01
  249.     #define SIG_SETMASK    02
  250.  
  251.     #define SA_NOCLDSTOP    04
  252.  
  253.     #if defined(__STDC__) && !defined(KERNEL)
  254.         extern int kill(pid_t pid, int sig);
  255.         extern int sigaction(int sig, \
  256.                              const struct sigaction *act, \
  257.                              struct sigaction *oact);
  258.         extern int sigaddset(sigset_t *set, int signo);
  259.         extern int sigdelset(sigset_t *set, int signo);
  260.         extern int sigemptyset(sigset_t *set);
  261.         extern int sigfillset(sigset_t *set);
  262.         extern int sigismember(const sigset_t *set, int signo);
  263.         extern int sigpending(sigset_t *set);
  264.         extern int sigprocmask(int how, const sigset_t *set, \
  265.                                sigset_t *oset);
  266.         extern int sigsuspend(const sigset_t *sigmask);
  267.     #else /* __STDC__ */
  268.         extern int kill();
  269.         extern int sigaction();
  270.         extern int sigaddset();
  271.         extern int sigdelset();
  272.         extern int sigemptyset();
  273.         extern int sigfillset();
  274.         extern int sigismember();
  275.         extern int sigpending();
  276.         extern int sigprocmask();
  277.         extern int sigsuspend();
  278.     #endif /* __STDC__ */
  279.  
  280. #endif /* _POSIX_SOURCE */
  281. #endif /* _SYS_SIGNAL_H */
  282.