1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. 3*0Sstevel@tonic-gate * All rights reserved. 4*0Sstevel@tonic-gate * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 5*0Sstevel@tonic-gate * Copyright (c) 1988, 1993 6*0Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 7*0Sstevel@tonic-gate * 8*0Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 9*0Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 10*0Sstevel@tonic-gate * the sendmail distribution. 11*0Sstevel@tonic-gate * 12*0Sstevel@tonic-gate * $Id: signal.h,v 1.16 2001/07/20 19:48:21 gshapiro Exp $ 13*0Sstevel@tonic-gate */ 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gate /* 18*0Sstevel@tonic-gate ** SIGNAL.H -- libsm (and sendmail) signal facilities 19*0Sstevel@tonic-gate ** Extracted from sendmail/conf.h and focusing 20*0Sstevel@tonic-gate ** on signal configuration. 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate #ifndef SM_SIGNAL_H 24*0Sstevel@tonic-gate #define SM_SIGNAL_H 1 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate #include <sys/types.h> 27*0Sstevel@tonic-gate #include <limits.h> 28*0Sstevel@tonic-gate #include <signal.h> 29*0Sstevel@tonic-gate #include <sm/cdefs.h> 30*0Sstevel@tonic-gate #include <sm/conf.h> 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate ** Critical signal sections 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #define PEND_SIGHUP 0x0001 37*0Sstevel@tonic-gate #define PEND_SIGINT 0x0002 38*0Sstevel@tonic-gate #define PEND_SIGTERM 0x0004 39*0Sstevel@tonic-gate #define PEND_SIGUSR1 0x0008 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate #define ENTER_CRITICAL() InCriticalSection++ 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate #define LEAVE_CRITICAL() \ 44*0Sstevel@tonic-gate do \ 45*0Sstevel@tonic-gate { \ 46*0Sstevel@tonic-gate if (InCriticalSection > 0) \ 47*0Sstevel@tonic-gate InCriticalSection--; \ 48*0Sstevel@tonic-gate } while (0) 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate #define CHECK_CRITICAL(sig) \ 51*0Sstevel@tonic-gate do \ 52*0Sstevel@tonic-gate { \ 53*0Sstevel@tonic-gate if (InCriticalSection > 0 && (sig) != 0) \ 54*0Sstevel@tonic-gate { \ 55*0Sstevel@tonic-gate pend_signal((sig)); \ 56*0Sstevel@tonic-gate return SIGFUNC_RETURN; \ 57*0Sstevel@tonic-gate } \ 58*0Sstevel@tonic-gate } while (0) 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate /* variables */ 61*0Sstevel@tonic-gate extern unsigned int volatile InCriticalSection; /* >0 if in critical section */ 62*0Sstevel@tonic-gate extern int volatile PendingSignal; /* pending signal to resend */ 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate /* functions */ 65*0Sstevel@tonic-gate extern void pend_signal __P((int)); 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate /* reset signal in case System V semantics */ 68*0Sstevel@tonic-gate #ifdef SYS5SIGNALS 69*0Sstevel@tonic-gate # define FIX_SYSV_SIGNAL(sig, handler) \ 70*0Sstevel@tonic-gate { \ 71*0Sstevel@tonic-gate if ((sig) != 0) \ 72*0Sstevel@tonic-gate (void) sm_signal((sig), (handler)); \ 73*0Sstevel@tonic-gate } 74*0Sstevel@tonic-gate #else /* SYS5SIGNALS */ 75*0Sstevel@tonic-gate # define FIX_SYSV_SIGNAL(sig, handler) { /* EMPTY */ } 76*0Sstevel@tonic-gate #endif /* SYS5SIGNALS */ 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate extern void sm_allsignals __P((bool)); 79*0Sstevel@tonic-gate extern int sm_blocksignal __P((int)); 80*0Sstevel@tonic-gate extern int sm_releasesignal __P((int)); 81*0Sstevel@tonic-gate extern sigfunc_t sm_signal __P((int, sigfunc_t)); 82*0Sstevel@tonic-gate extern SIGFUNC_DECL sm_signal_noop __P((int)); 83*0Sstevel@tonic-gate #endif /* SM_SIGNAL_H */ 84