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