home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / signal / signal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-18  |  7.7 KB  |  243 lines

  1. /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    ANSI Standard: 4.7 SIGNAL HANDLING <signal.h>
  21.  */
  22.  
  23. #ifndef    _SIGNAL_H
  24.  
  25. #if    !defined(__need_sig_atomic_t) && !defined(__need_sigset_t)
  26. #define    _SIGNAL_H    1
  27. #include <features.h>
  28. #endif
  29.  
  30. __BEGIN_DECLS
  31.  
  32. #define     __need_size_t
  33. #include <stddef.h>
  34.  
  35. #include <gnu/types.h>
  36. #include <sigset.h>        /* __sigset_t, __sig_atomic_t.  */
  37. #include <signum.h>
  38.  
  39. #if    !defined(__sig_atomic_t_defined) &&    \
  40.   (defined(_SIGNAL_H) || defined(__need_sig_atomic_t))
  41. /* An integral type that can be modified atomically, without the
  42.    possibility of a signal arriving in the middle of the operation.  */
  43. typedef __sig_atomic_t sig_atomic_t;
  44. #endif /* `sig_atomic_t' undefined and <signal.h> or need `sig_atomic_t'.  */
  45. #undef    __need_sig_atomic_t
  46.  
  47. #ifdef    _SIGNAL_H
  48.  
  49. /* Type of a signal handler.  */
  50. typedef void (*__sighandler_t) __P ((int));
  51.  
  52. /* Set the handler for the signal SIG to HANDLER,
  53.    returning the old handler, or SIG_ERR on error.  */
  54. extern __sighandler_t signal __P ((int __sig, __sighandler_t __handler));
  55.  
  56. /* Send signal SIG to process number PID.  If PID is zero,
  57.    send SIG to all processes in the current process's process group.
  58.    If PID is < -1, send SIG to all processes in process group - PID.  */
  59. extern int __kill __P ((__pid_t __pid, int __sig));
  60. #ifdef    __USE_POSIX
  61. extern int kill __P ((__pid_t __pid, int __sig));
  62. #endif /* Use POSIX.  */
  63.  
  64. #ifdef    __USE_BSD
  65. /* Send SIG to all processes in process group PGRP.
  66.    If PGRP is zero, send SIG to all processes in
  67.    the current process's process group.  */
  68. extern int killpg __P ((int __pgrp, int __sig));
  69. #endif /* Use BSD.  */
  70.  
  71. /* Raise signal SIG, i.e., send SIG to yourself.  */
  72. extern int raise __P ((int __sig));
  73.  
  74. #ifdef    __USE_SVID
  75. /* SVID names for the same things.  */
  76. extern __sighandler_t ssignal __P ((int __sig, __sighandler_t __handler));
  77. extern int gsignal __P ((int __sig));
  78. #endif /* Use SVID.  */
  79.  
  80.  
  81. /* Block signals in MASK, returning the old mask.  */
  82. extern int __sigblock __P ((int __mask));
  83.  
  84. /* Set the mask of blocked signals to MASK, returning the old mask.  */
  85. extern int __sigsetmask __P ((int __mask));
  86.  
  87. /* Set the mask of blocked signals to MASK,
  88.    wait for a signal to arrive, and then restore the mask.  */
  89. extern int __sigpause __P ((int __mask));
  90.  
  91. #ifdef    __USE_BSD
  92. #define    sigmask(sig)    __sigmask(sig)
  93.  
  94. extern int sigblock __P ((int __mask));
  95. extern int sigsetmask __P ((int __mask));
  96. extern int sigpause __P ((int __mask));
  97. #endif /* Use BSD.  */
  98.  
  99.  
  100. #ifdef    __USE_MISC
  101. #define    NSIG    _NSIG
  102. #endif
  103.  
  104. #ifdef    __USE_GNU
  105. typedef __sighandler_t sighandler_t;
  106. #endif
  107.  
  108. #endif /* <signal.h> included.  */
  109.  
  110.  
  111. #ifdef    __USE_POSIX
  112.  
  113. #if    !defined(__sigset_t_defined) &&    \
  114.    (defined(_SIGNAL_H) || defined(__need_sigset_t))
  115. typedef __sigset_t sigset_t;
  116. #define    __sigset_t_defined    1
  117. #endif /* `sigset_t' not defined and <signal.h> or need `sigset_t'.  */
  118. #undef    __need_sigset_t
  119.  
  120. #ifdef    _SIGNAL_H
  121.  
  122. /* Clear all signals from SET.  */
  123. extern int sigemptyset __P ((sigset_t *__set));
  124.  
  125. /* Set all signals in SET.  */
  126. extern int sigfillset __P ((sigset_t *__set));
  127.  
  128. /* Add SIGNO to SET.  */
  129. extern int sigaddset __P ((sigset_t *__set, int __signo));
  130.  
  131. /* Remove SIGNO from SET.  */
  132. extern int sigdelset __P ((sigset_t *__set, int __signo));
  133.  
  134. /* Return 1 if SIGNO is in SET, 0 if not.  */
  135. extern int sigismember __P ((__const sigset_t *__set, int signo));
  136.  
  137. #ifdef    __OPTIMIZE__
  138. /* <sigset.h> defines the __ versions as macros that do the work.  */
  139. #define    sigemptyset(set)    __sigemptyset(set)
  140. #define    sigfillset(set)        __sigfillset(set)
  141. #define    sigaddset(set, signo)    __sigaddset(set, signo)
  142. #define    sigdelset(set, signo)    __sigdelset(set, signo)
  143. #define    sigismember(set, signo)    __sigismember(set, signo)
  144. #endif
  145.  
  146. /* Get the system-specific definitions of `struct sigaction'
  147.    and the `SA_*' and `SIG_*'. constants.  */
  148. #include <sigaction.h>
  149.  
  150. /* Get and/or change the set of blocked signals.  */
  151. extern int __sigprocmask __P ((int __how,
  152.                    __const sigset_t *__set, sigset_t *__oset));
  153. extern int sigprocmask __P ((int __how,
  154.                  __const sigset_t *__set, sigset_t *__oset));
  155.  
  156. /* Change the set of blocked signals to SET,
  157.    wait until a signal arrives, and restore the set of blocked signals.  */
  158. extern int sigsuspend __P ((__const sigset_t *__set));
  159.  
  160. /* Get and/or set the action for signal SIG.  */
  161. extern int __sigaction __P ((int __sig, __const struct sigaction *__act,
  162.                  struct sigaction *__oact));
  163. extern int sigaction __P ((int __sig, __const struct sigaction *__act,
  164.                struct sigaction *__oact));
  165.  
  166. /* Put in SET all signals that are blocked and waiting to be delivered.  */
  167. extern int sigpending __P ((sigset_t *__set));
  168.  
  169. #endif /* <signal.h> included.  */
  170.  
  171. #endif /* Use POSIX.  */
  172.  
  173. #if    defined(_SIGNAL_H) && defined(__USE_BSD)
  174.  
  175. /* Structure passed to `sigvec'.  */
  176. struct sigvec
  177.   {
  178.     __sighandler_t sv_handler;    /* Signal handler.  */
  179.     int sv_mask;        /* Mask of signals to be blocked.  */
  180.  
  181.     int sv_flags;        /* Flags (see below).  */
  182. #define    sv_onstack    sv_flags /* 4.2 BSD compatibility.  */
  183.   };
  184.  
  185. /* Bits in `sv_flags'.  */
  186. #define    SV_ONSTACK    (1 << 0)/* Take the signal on the signal stack.  */
  187. #define    SV_INTERRUPT    (1 << 1)/* Do not restart system calls.  */
  188. #define    SV_RESETHAND    (1 << 2)/* Reset handler to SIG_DFL on receipt.  */
  189.  
  190.  
  191. /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
  192.    of VEC.  The signals in `sv_mask' will be blocked while the handler runs.
  193.    If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
  194.    reset to SIG_DFL before `sv_handler' is entered.  If OVEC is non-NULL,
  195.    it is filled in with the old information for SIG.  */
  196. extern int __sigvec __P ((int __sig, __const struct sigvec *__vec,
  197.               struct sigvec *__ovec));
  198. extern int sigvec __P ((int __sig, __const struct sigvec *__vec,
  199.             struct sigvec *__ovec));
  200.  
  201.  
  202. /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
  203.    (causing them to fail with EINTR); if INTERRUPT is zero, make system
  204.    calls be restarted after signal SIG.  */
  205. extern int siginterrupt __P ((int __sig, int __interrupt));
  206.  
  207.  
  208. /* Structure describing a signal stack.  */
  209. struct sigstack
  210.   {
  211.     __ptr_t ss_sp;        /* Signal stack pointer.  */
  212.     int ss_onstack;        /* Nonzero if executing on this stack.  */
  213.   };
  214.  
  215. /* Run signals handlers on the stack specified by SS (if not NULL).
  216.    If OSS is not NULL, it is filled in with the old signal stack status.  */
  217. extern int sigstack __P ((__const struct sigstack *__ss,
  218.               struct sigstack *__oss));
  219.  
  220. /* Alternate interface.  */
  221. struct sigaltstack
  222.   {
  223.     __ptr_t ss_sp;
  224.     size_t ss_size;
  225.     int ss_flags;
  226.   };
  227.  
  228. extern int sigaltstack __P ((__const struct sigaltstack *__ss,
  229.                  struct sigaltstack *__oss));
  230.  
  231. /* Get machine-dependent `struct sigcontext' and signal subcodes.  */
  232. #include <sigcontext.h>
  233.  
  234. /* Restore the state saved in SCP.  */
  235. extern int __sigreturn __P ((__const struct sigcontext *__scp));
  236. extern int sigreturn __P ((__const struct sigcontext *__scp));
  237.  
  238. #endif /* signal.h included and use BSD.  */
  239.  
  240. __END_DECLS
  241.  
  242. #endif /* signal.h  */
  243.