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