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