home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / pdksh-4.9-src.tgz / tar.out / contrib / pdksh / sh / sigact.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  111 lines

  1. /* NAME:
  2.  *      sigact.h - sigaction et al
  3.  *
  4.  * SYNOPSIS:
  5.  *      #include "sigact.h"
  6.  *
  7.  * DESCRIPTION:
  8.  *      This header is the interface to a fake sigaction(2) 
  9.  *      implementation. It provides a POSIX compliant interface 
  10.  *      to whatever signal handling mechanisms are available.
  11.  *      It also provides a Signal() function that is implemented 
  12.  *      in terms of sigaction().
  13.  *      If not using signal(2) as part of the underlying 
  14.  *      implementation (USE_SIGNAL or USE_SIGMASK), and 
  15.  *      NO_SIGNAL is not defined, it also provides a signal() 
  16.  *      function that calls Signal(). 
  17.  *      
  18.  * SEE ALSO:
  19.  *      sigact.c
  20.  */
  21. /*
  22.  * RCSid:
  23.  *      $Id: sigact.h,v 1.5 93/05/05 21:17:04 sjg Exp $
  24.  */
  25. #ifndef _SIGACT_H
  26. #define _SIGACT_H
  27.  
  28. /*
  29.  * most modern systems use void for signal handlers but
  30.  * not all.
  31.  */
  32. #ifndef SIG_HDLR
  33. # define SIG_HDLR void
  34. #endif
  35.  
  36. #undef ARGS
  37. #if defined(__STDC__) || defined(__cplusplus)
  38. # define ARGS(p) p
  39. #else
  40. # define ARGS(p) ()
  41. # define volatile            /* don't optimize please */
  42. # define const                /* read only */
  43. #endif
  44.  
  45. SIG_HDLR (*Signal    ARGS((int sig, SIG_HDLR (*disp)(int)))) ARGS((int)); 
  46.  
  47. /*
  48.  * if you want to install this header as signal.h,
  49.  * modify this to pick up the original signal.h
  50.  */
  51. #ifndef SIGKILL
  52. # include <signal.h>
  53. #endif
  54.   
  55. #ifndef SIG_ERR
  56. # define SIG_ERR  (SIG_HDLR (*)())-1
  57. #endif
  58. #ifndef BADSIG
  59. # define BADSIG  SIG_ERR
  60. #endif
  61.     
  62. #ifndef SA_NOCLDSTOP
  63. /* we assume we need the fake sigaction */
  64. /* sa_flags */
  65. #define    SA_NOCLDSTOP    1        /* don't send SIGCHLD on child stop */
  66. #define SA_RESTART    2        /* re-start I/O */
  67.  
  68. /* sigprocmask flags */
  69. #define    SIG_BLOCK    1
  70. #define    SIG_UNBLOCK    2
  71. #define    SIG_SETMASK    4
  72.  
  73. /*
  74.  * this is a bit untidy
  75.  */
  76. #if !defined(__sys_stdtypes_h)
  77. typedef unsigned int sigset_t;
  78. #endif
  79.   
  80. /*
  81.  * POSIX sa_handler should return void, but since we are
  82.  * implementing in terms of something else, it may
  83.  * be appropriate to use the normal SIG_HDLR return type
  84.  */
  85. struct sigaction
  86. {
  87.   SIG_HDLR    (*sa_handler)();
  88.   sigset_t    sa_mask;
  89.   int        sa_flags;
  90. };
  91.  
  92.  
  93. int    sigaction    ARGS(( int sig, struct sigaction *act, struct sigaction *oact ));
  94. int    sigaddset    ARGS(( sigset_t *mask, int sig ));
  95. int    sigdelset    ARGS(( sigset_t *mask, int sig ));
  96. int    sigemptyset    ARGS(( sigset_t *mask ));
  97. int    sigfillset    ARGS(( sigset_t *mask ));
  98. int    sigismember    ARGS(( sigset_t *mask, int sig ));
  99. int    sigpending    ARGS(( sigset_t *set ));
  100. int    sigprocmask    ARGS(( int how, sigset_t *set, sigset_t *oset ));
  101. int    sigsuspend    ARGS(( sigset_t *mask ));
  102.     
  103. #ifndef sigmask
  104. # define sigmask(s)    (1<<((s)-1))    /* convert SIGnum to mask */
  105. #endif
  106. #if !defined(NSIG) && defined(_NSIG)
  107. # define NSIG _NSIG
  108. #endif
  109. #endif /* ! SA_NOCLDSTOP */
  110. #endif /* _SIGACT_H */
  111.