xref: /freebsd/contrib/bmake/sigaction.c (revision 129043849f62f9cfa72f6fae68417d9995860f3f)
1*12904384SSimon J. Gerraty /* NAME:
2*12904384SSimon J. Gerraty  *      sigact.c - fake sigaction(2)
3*12904384SSimon J. Gerraty  *
4*12904384SSimon J. Gerraty  * SYNOPSIS:
5*12904384SSimon J. Gerraty  *      #include "sigact.h"
6*12904384SSimon J. Gerraty  *
7*12904384SSimon J. Gerraty  *      int sigaction(int sig, struct sigaction *act,
8*12904384SSimon J. Gerraty  *                      struct sigaction *oact);
9*12904384SSimon J. Gerraty  *      int sigaddset(sigset_t *mask, int sig);
10*12904384SSimon J. Gerraty  *      int sigdelset(sigset_t *mask, int sig);
11*12904384SSimon J. Gerraty  *      int sigemptyset(sigset_t *mask);
12*12904384SSimon J. Gerraty  *      int sigfillset(sigset_t *mask);
13*12904384SSimon J. Gerraty  *      int sigismember(sigset_t *mask, int sig);
14*12904384SSimon J. Gerraty  *      int sigpending(sigset_t *set);
15*12904384SSimon J. Gerraty  *      int sigprocmask(int how, sigset_t *set, sigset_t *oset);
16*12904384SSimon J. Gerraty  *      int sigsuspend(sigset_t *mask);
17*12904384SSimon J. Gerraty  *
18*12904384SSimon J. Gerraty  *      SIG_HDLR (*Signal(int sig, SIG_HDLR (*disp)(int)))(int);
19*12904384SSimon J. Gerraty  *
20*12904384SSimon J. Gerraty  * DESCRIPTION:
21*12904384SSimon J. Gerraty  *      This is a fake sigaction implementation.  It uses
22*12904384SSimon J. Gerraty  *      sigsetmask(2) et al or sigset(2) and friends if
23*12904384SSimon J. Gerraty  *      available, otherwise it just uses signal(2).  If it
24*12904384SSimon J. Gerraty  *      thinks sigaction(2) really exists it compiles to "almost"
25*12904384SSimon J. Gerraty  *      nothing.
26*12904384SSimon J. Gerraty  *
27*12904384SSimon J. Gerraty  *      In any case it provides a Signal() function that is
28*12904384SSimon J. Gerraty  *      implemented in terms of sigaction().
29*12904384SSimon J. Gerraty  *      If not using signal(2) as part of the underlying
30*12904384SSimon J. Gerraty  *      implementation (USE_SIGNAL or USE_SIGMASK), and
31*12904384SSimon J. Gerraty  *      NO_SIGNAL is not defined, it also provides a signal()
32*12904384SSimon J. Gerraty  *      function that calls Signal().
33*12904384SSimon J. Gerraty  *
34*12904384SSimon J. Gerraty  *      The need for all this mucking about is the problems
35*12904384SSimon J. Gerraty  *      caused by mixing various signal handling mechanisms in
36*12904384SSimon J. Gerraty  *      the one process.  This module allows for a consistent
37*12904384SSimon J. Gerraty  *      POSIX compliant interface to whatever is actually
38*12904384SSimon J. Gerraty  *      available.
39*12904384SSimon J. Gerraty  *
40*12904384SSimon J. Gerraty  *      sigaction() allows the caller to examine and/or set the
41*12904384SSimon J. Gerraty  *      action to be associated with a given signal. "act" and
42*12904384SSimon J. Gerraty  *      "oact" are pointers to 'sigaction structs':
43*12904384SSimon J. Gerraty  *.nf
44*12904384SSimon J. Gerraty  *
45*12904384SSimon J. Gerraty  *      struct sigaction
46*12904384SSimon J. Gerraty  *      {
47*12904384SSimon J. Gerraty  *             SIG_HDLR  (*sa_handler)();
48*12904384SSimon J. Gerraty  *             sigset_t  sa_mask;
49*12904384SSimon J. Gerraty  *             int       sa_flags;
50*12904384SSimon J. Gerraty  *      };
51*12904384SSimon J. Gerraty  *.fi
52*12904384SSimon J. Gerraty  *
53*12904384SSimon J. Gerraty  *      SIG_HDLR is normally 'void' in the POSIX implementation
54*12904384SSimon J. Gerraty  *      and for most current systems.  On some older UNIX
55*12904384SSimon J. Gerraty  *      systems, signal handlers do not return 'void', so
56*12904384SSimon J. Gerraty  *      this implementation keeps 'sa_handler' inline with the
57*12904384SSimon J. Gerraty  *      hosts normal signal handling conventions.
58*12904384SSimon J. Gerraty  *      'sa_mask' controls which signals will be blocked while
59*12904384SSimon J. Gerraty  *      the selected signal handler is active.  It is not used
60*12904384SSimon J. Gerraty  *      in this implementation.
61*12904384SSimon J. Gerraty  *      'sa_flags' controls various semantics such as whether
62*12904384SSimon J. Gerraty  *      system calls should be automagically restarted
63*12904384SSimon J. Gerraty  *      (SA_RESTART) etc.  It is not used in this
64*12904384SSimon J. Gerraty  *      implementation.
65*12904384SSimon J. Gerraty  *      Either "act" or "oact" may be NULL in which case the
66*12904384SSimon J. Gerraty  *      appropriate operation is skipped.
67*12904384SSimon J. Gerraty  *
68*12904384SSimon J. Gerraty  *      sigaddset() adds "sig" to the sigset_t pointed to by "mask".
69*12904384SSimon J. Gerraty  *
70*12904384SSimon J. Gerraty  *      sigdelset() removes "sig" from the sigset_t pointed to
71*12904384SSimon J. Gerraty  *      by "mask".
72*12904384SSimon J. Gerraty  *
73*12904384SSimon J. Gerraty  *      sigemptyset() makes the sigset_t pointed to by "mask" empty.
74*12904384SSimon J. Gerraty  *
75*12904384SSimon J. Gerraty  *      sigfillset() makes the sigset_t pointed to by "mask"
76*12904384SSimon J. Gerraty  *      full ie. match all signals.
77*12904384SSimon J. Gerraty  *
78*12904384SSimon J. Gerraty  *      sigismember() returns true if "sig" is found in "*mask".
79*12904384SSimon J. Gerraty  *
80*12904384SSimon J. Gerraty  *      sigpending() is supposed to return "set" loaded with the
81*12904384SSimon J. Gerraty  *      set of signals that are blocked and pending for the
82*12904384SSimon J. Gerraty  *      calling process.  It does nothing in this impementation.
83*12904384SSimon J. Gerraty  *
84*12904384SSimon J. Gerraty  *      sigprocmask() is used to examine and/or change the
85*12904384SSimon J. Gerraty  *      signal mask for the calling process.  Either "set" or
86*12904384SSimon J. Gerraty  *      "oset" may be NULL in which case the appropriate
87*12904384SSimon J. Gerraty  *      operation is skipped.  "how" may be one of SIG_BLOCK,
88*12904384SSimon J. Gerraty  *      SIG_UNBLOCK or SIG_SETMASK.  If this package is built
89*12904384SSimon J. Gerraty  *      with USE_SIGNAL, then this routine achieves nothing.
90*12904384SSimon J. Gerraty  *
91*12904384SSimon J. Gerraty  *      sigsuspend() sets the signal mask to "*mask" and waits
92*12904384SSimon J. Gerraty  *      for a signal to be delivered after which the previous
93*12904384SSimon J. Gerraty  *      mask is restored.
94*12904384SSimon J. Gerraty  *
95*12904384SSimon J. Gerraty  *
96*12904384SSimon J. Gerraty  * RETURN VALUE:
97*12904384SSimon J. Gerraty  *      0==success, -1==failure
98*12904384SSimon J. Gerraty  *
99*12904384SSimon J. Gerraty  * BUGS:
100*12904384SSimon J. Gerraty  *      Since we fake most of this, don't expect fancy usage to
101*12904384SSimon J. Gerraty  *      work.
102*12904384SSimon J. Gerraty  *
103*12904384SSimon J. Gerraty  * AUTHOR:
104*12904384SSimon J. Gerraty  *      Simon J. Gerraty <sjg@crufty.net>
105*12904384SSimon J. Gerraty  */
106*12904384SSimon J. Gerraty /* COPYRIGHT:
107*12904384SSimon J. Gerraty  *      @(#)Copyright (c) 1992-2021, Simon J. Gerraty
108*12904384SSimon J. Gerraty  *
109*12904384SSimon J. Gerraty  *      This is free software.  It comes with NO WARRANTY.
110*12904384SSimon J. Gerraty  *      Permission to use, modify and distribute this source code
111*12904384SSimon J. Gerraty  *      is granted subject to the following conditions.
112*12904384SSimon J. Gerraty  *      1/ that that the above copyright notice and this notice
113*12904384SSimon J. Gerraty  *      are preserved in all copies and that due credit be given
114*12904384SSimon J. Gerraty  *      to the author.
115*12904384SSimon J. Gerraty  *      2/ that any changes to this code are clearly commented
116*12904384SSimon J. Gerraty  *      as such so that the author does get blamed for bugs
117*12904384SSimon J. Gerraty  *      other than his own.
118*12904384SSimon J. Gerraty  *
119*12904384SSimon J. Gerraty  *      Please send copies of changes and bug-fixes to:
120*12904384SSimon J. Gerraty  *      sjg@crufty.net
121*12904384SSimon J. Gerraty  *
122*12904384SSimon J. Gerraty  */
123*12904384SSimon J. Gerraty #ifndef lint
124*12904384SSimon J. Gerraty static char *RCSid = "$Id: sigact.c,v 1.8 2021/10/14 19:39:17 sjg Exp $";
125*12904384SSimon J. Gerraty #endif
126*12904384SSimon J. Gerraty 
127*12904384SSimon J. Gerraty #undef _ANSI_SOURCE		/* causes problems */
128*12904384SSimon J. Gerraty 
129*12904384SSimon J. Gerraty #include <signal.h>
130*12904384SSimon J. Gerraty #include <sys/cdefs.h>
131*12904384SSimon J. Gerraty 
132*12904384SSimon J. Gerraty #ifdef HAVE_CONFIG_H
133*12904384SSimon J. Gerraty # include "config.h"
134*12904384SSimon J. Gerraty # ifdef NO_SIGSET
135*12904384SSimon J. Gerraty #   undef HAVE_SIGSET
136*12904384SSimon J. Gerraty # endif
137*12904384SSimon J. Gerraty # ifndef HAVE_SIGACTION
138*12904384SSimon J. Gerraty #   ifdef HAVE_SIGSETMASK
139*12904384SSimon J. Gerraty #     define USE_SIGMASK
140*12904384SSimon J. Gerraty #   else
141*12904384SSimon J. Gerraty #     ifdef HAVE_SIGSET
142*12904384SSimon J. Gerraty #       define USE_SIGSET
143*12904384SSimon J. Gerraty #     else
144*12904384SSimon J. Gerraty #       define USE_SIGNAL
145*12904384SSimon J. Gerraty #     endif
146*12904384SSimon J. Gerraty #   endif
147*12904384SSimon J. Gerraty # endif
148*12904384SSimon J. Gerraty #endif
149*12904384SSimon J. Gerraty 
150*12904384SSimon J. Gerraty /*
151*12904384SSimon J. Gerraty  * some systems have a faulty sigaction() implementation!
152*12904384SSimon J. Gerraty  * Allow us to bypass it.
153*12904384SSimon J. Gerraty  * Or they may have installed sigact.h as signal.h which is why
154*12904384SSimon J. Gerraty  * we have SA_NOCLDSTOP defined.
155*12904384SSimon J. Gerraty  */
156*12904384SSimon J. Gerraty #if !defined(SA_NOCLDSTOP) || defined(_SIGACT_H) || defined(USE_SIGNAL) || defined(USE_SIGSET) || defined(USE_SIGMASK)
157*12904384SSimon J. Gerraty 
158*12904384SSimon J. Gerraty /*
159*12904384SSimon J. Gerraty  * if we haven't been told,
160*12904384SSimon J. Gerraty  * try and guess what we should implement with.
161*12904384SSimon J. Gerraty  */
162*12904384SSimon J. Gerraty #if !defined(USE_SIGSET) && !defined(USE_SIGMASK) && !defined(USE_SIGNAL)
163*12904384SSimon J. Gerraty # if defined(sigmask) || defined(BSD) || defined(_BSD) && !defined(BSD41)
164*12904384SSimon J. Gerraty #   define USE_SIGMASK
165*12904384SSimon J. Gerraty # else
166*12904384SSimon J. Gerraty #   ifndef NO_SIGSET
167*12904384SSimon J. Gerraty #     define USE_SIGSET
168*12904384SSimon J. Gerraty #   else
169*12904384SSimon J. Gerraty #     define USE_SIGNAL
170*12904384SSimon J. Gerraty #   endif
171*12904384SSimon J. Gerraty # endif
172*12904384SSimon J. Gerraty #endif
173*12904384SSimon J. Gerraty /*
174*12904384SSimon J. Gerraty  * if we still don't know, we're in trouble
175*12904384SSimon J. Gerraty  */
176*12904384SSimon J. Gerraty #if !defined(USE_SIGSET) && !defined(USE_SIGMASK) && !defined(USE_SIGNAL)
177*12904384SSimon J. Gerraty error must know what to implement with
178*12904384SSimon J. Gerraty #endif
179*12904384SSimon J. Gerraty 
180*12904384SSimon J. Gerraty #include "sigact.h"
181*12904384SSimon J. Gerraty 
182*12904384SSimon J. Gerraty /*
183*12904384SSimon J. Gerraty  * in case signal() has been mapped to our Signal().
184*12904384SSimon J. Gerraty  */
185*12904384SSimon J. Gerraty #undef signal
186*12904384SSimon J. Gerraty 
187*12904384SSimon J. Gerraty 
188*12904384SSimon J. Gerraty int
sigaction(int sig,const struct sigaction * act,struct sigaction * oact)189*12904384SSimon J. Gerraty sigaction(int sig,
190*12904384SSimon J. Gerraty     const struct sigaction *act,
191*12904384SSimon J. Gerraty     struct sigaction *oact)
192*12904384SSimon J. Gerraty {
193*12904384SSimon J. Gerraty 	SIG_HDLR(*oldh) ();
194*12904384SSimon J. Gerraty 
195*12904384SSimon J. Gerraty 	if (act) {
196*12904384SSimon J. Gerraty #ifdef USE_SIGSET
197*12904384SSimon J. Gerraty 		oldh = sigset(sig, act->sa_handler);
198*12904384SSimon J. Gerraty #else
199*12904384SSimon J. Gerraty 		oldh = signal(sig, act->sa_handler);
200*12904384SSimon J. Gerraty #endif
201*12904384SSimon J. Gerraty 	} else {
202*12904384SSimon J. Gerraty 		if (oact) {
203*12904384SSimon J. Gerraty #ifdef USE_SIGSET
204*12904384SSimon J. Gerraty 			oldh = sigset(sig, SIG_IGN);
205*12904384SSimon J. Gerraty #else
206*12904384SSimon J. Gerraty 			oldh = signal(sig, SIG_IGN);
207*12904384SSimon J. Gerraty #endif
208*12904384SSimon J. Gerraty 			if (oldh != SIG_IGN && oldh != SIG_ERR) {
209*12904384SSimon J. Gerraty #ifdef USE_SIGSET
210*12904384SSimon J. Gerraty 				(void) sigset(sig, oldh);
211*12904384SSimon J. Gerraty #else
212*12904384SSimon J. Gerraty 				(void) signal(sig, oldh);
213*12904384SSimon J. Gerraty #endif
214*12904384SSimon J. Gerraty 			}
215*12904384SSimon J. Gerraty 		}
216*12904384SSimon J. Gerraty 	}
217*12904384SSimon J. Gerraty 	if (oact) {
218*12904384SSimon J. Gerraty 		oact->sa_handler = oldh;
219*12904384SSimon J. Gerraty 	}
220*12904384SSimon J. Gerraty 	return 0;		/* hey we're faking it */
221*12904384SSimon J. Gerraty }
222*12904384SSimon J. Gerraty 
223*12904384SSimon J. Gerraty #ifndef HAVE_SIGADDSET
224*12904384SSimon J. Gerraty int
sigaddset(sigset_t * mask,int sig)225*12904384SSimon J. Gerraty sigaddset(sigset_t *mask, int sig)
226*12904384SSimon J. Gerraty {
227*12904384SSimon J. Gerraty 	*mask |= sigmask(sig);
228*12904384SSimon J. Gerraty 	return 0;
229*12904384SSimon J. Gerraty }
230*12904384SSimon J. Gerraty 
231*12904384SSimon J. Gerraty 
232*12904384SSimon J. Gerraty int
sigdelset(sigset_t * mask,int sig)233*12904384SSimon J. Gerraty sigdelset(sigset_t *mask, int sig)
234*12904384SSimon J. Gerraty {
235*12904384SSimon J. Gerraty 	*mask &= ~(sigmask(sig));
236*12904384SSimon J. Gerraty 	return 0;
237*12904384SSimon J. Gerraty }
238*12904384SSimon J. Gerraty 
239*12904384SSimon J. Gerraty 
240*12904384SSimon J. Gerraty int
sigemptyset(sigset_t * mask)241*12904384SSimon J. Gerraty sigemptyset(sigset_t *mask)
242*12904384SSimon J. Gerraty {
243*12904384SSimon J. Gerraty 	*mask = 0;
244*12904384SSimon J. Gerraty 	return 0;
245*12904384SSimon J. Gerraty }
246*12904384SSimon J. Gerraty 
247*12904384SSimon J. Gerraty 
248*12904384SSimon J. Gerraty int
sigfillset(sigset_t * mask)249*12904384SSimon J. Gerraty sigfillset(sigset_t *mask)
250*12904384SSimon J. Gerraty {
251*12904384SSimon J. Gerraty 	*mask = ~0;
252*12904384SSimon J. Gerraty 	return 0;
253*12904384SSimon J. Gerraty }
254*12904384SSimon J. Gerraty 
255*12904384SSimon J. Gerraty 
256*12904384SSimon J. Gerraty int
sigismember(const sigset_t * mask,int sig)257*12904384SSimon J. Gerraty sigismember(const sigset_t *mask, int sig)
258*12904384SSimon J. Gerraty {
259*12904384SSimon J. Gerraty 	return ((*mask) & sigmask(sig));
260*12904384SSimon J. Gerraty }
261*12904384SSimon J. Gerraty #endif
262*12904384SSimon J. Gerraty 
263*12904384SSimon J. Gerraty #ifndef HAVE_SIGPENDING
264*12904384SSimon J. Gerraty int
sigpending(sigset_t * set)265*12904384SSimon J. Gerraty sigpending(sigset_t *set)
266*12904384SSimon J. Gerraty {
267*12904384SSimon J. Gerraty 	return 0;		/* faking it! */
268*12904384SSimon J. Gerraty }
269*12904384SSimon J. Gerraty #endif
270*12904384SSimon J. Gerraty 
271*12904384SSimon J. Gerraty #ifndef HAVE_SIGPROCMASK
272*12904384SSimon J. Gerraty int
sigprocmask(int how,const sigset_t * set,sigset_t * oset)273*12904384SSimon J. Gerraty sigprocmask(int how, const sigset_t *set, sigset_t *oset)
274*12904384SSimon J. Gerraty {
275*12904384SSimon J. Gerraty #ifdef USE_SIGSET
276*12904384SSimon J. Gerraty 	int i;
277*12904384SSimon J. Gerraty #endif
278*12904384SSimon J. Gerraty 	static sigset_t sm;
279*12904384SSimon J. Gerraty 	static int once = 0;
280*12904384SSimon J. Gerraty 
281*12904384SSimon J. Gerraty 	if (!once) {
282*12904384SSimon J. Gerraty 		/*
283*12904384SSimon J. Gerraty 	         * initally we clear sm,
284*12904384SSimon J. Gerraty 	         * there after, it represents the last
285*12904384SSimon J. Gerraty 	         * thing we did.
286*12904384SSimon J. Gerraty 	         */
287*12904384SSimon J. Gerraty 		once++;
288*12904384SSimon J. Gerraty #ifdef USE_SIGMASK
289*12904384SSimon J. Gerraty 		sm = sigblock(0);
290*12904384SSimon J. Gerraty #else
291*12904384SSimon J. Gerraty 		sm = 0;
292*12904384SSimon J. Gerraty #endif
293*12904384SSimon J. Gerraty 	}
294*12904384SSimon J. Gerraty 	if (oset)
295*12904384SSimon J. Gerraty 		*oset = sm;
296*12904384SSimon J. Gerraty 	if (set) {
297*12904384SSimon J. Gerraty 		switch (how) {
298*12904384SSimon J. Gerraty 		case SIG_BLOCK:
299*12904384SSimon J. Gerraty 			sm |= *set;
300*12904384SSimon J. Gerraty 			break;
301*12904384SSimon J. Gerraty 		case SIG_UNBLOCK:
302*12904384SSimon J. Gerraty 			sm &= ~(*set);
303*12904384SSimon J. Gerraty 			break;
304*12904384SSimon J. Gerraty 		case SIG_SETMASK:
305*12904384SSimon J. Gerraty 			sm = *set;
306*12904384SSimon J. Gerraty 			break;
307*12904384SSimon J. Gerraty 		}
308*12904384SSimon J. Gerraty #ifdef USE_SIGMASK
309*12904384SSimon J. Gerraty 		(void) sigsetmask(sm);
310*12904384SSimon J. Gerraty #else
311*12904384SSimon J. Gerraty #ifdef USE_SIGSET
312*12904384SSimon J. Gerraty 		for (i = 1; i < NSIG; i++) {
313*12904384SSimon J. Gerraty 			if (how == SIG_UNBLOCK) {
314*12904384SSimon J. Gerraty 				if (*set & sigmask(i))
315*12904384SSimon J. Gerraty 					sigrelse(i);
316*12904384SSimon J. Gerraty 			} else
317*12904384SSimon J. Gerraty 				if (sm & sigmask(i)) {
318*12904384SSimon J. Gerraty 					sighold(i);
319*12904384SSimon J. Gerraty 				}
320*12904384SSimon J. Gerraty 		}
321*12904384SSimon J. Gerraty #endif
322*12904384SSimon J. Gerraty #endif
323*12904384SSimon J. Gerraty 	}
324*12904384SSimon J. Gerraty 	return 0;
325*12904384SSimon J. Gerraty }
326*12904384SSimon J. Gerraty #endif
327*12904384SSimon J. Gerraty 
328*12904384SSimon J. Gerraty #ifndef HAVE_SIGSUSPEND
329*12904384SSimon J. Gerraty int
sigsuspend(sigset_t * mask)330*12904384SSimon J. Gerraty sigsuspend(sigset_t *mask)
331*12904384SSimon J. Gerraty {
332*12904384SSimon J. Gerraty #ifdef USE_SIGMASK
333*12904384SSimon J. Gerraty 	sigpause(*mask);
334*12904384SSimon J. Gerraty #else
335*12904384SSimon J. Gerraty 	int i;
336*12904384SSimon J. Gerraty 
337*12904384SSimon J. Gerraty #ifdef USE_SIGSET
338*12904384SSimon J. Gerraty 
339*12904384SSimon J. Gerraty 	for (i = 1; i < NSIG; i++) {
340*12904384SSimon J. Gerraty 		if (*mask & sigmask(i)) {
341*12904384SSimon J. Gerraty 			/* not the same sigpause() as above! */
342*12904384SSimon J. Gerraty 			sigpause(i);
343*12904384SSimon J. Gerraty 			break;
344*12904384SSimon J. Gerraty 		}
345*12904384SSimon J. Gerraty 	}
346*12904384SSimon J. Gerraty #else				/* signal(2) only */
347*12904384SSimon J. Gerraty 	SIG_HDLR(*oldh) ();
348*12904384SSimon J. Gerraty 
349*12904384SSimon J. Gerraty 	/*
350*12904384SSimon J. Gerraty          * make sure that signals in mask will not
351*12904384SSimon J. Gerraty          * be ignored.
352*12904384SSimon J. Gerraty          */
353*12904384SSimon J. Gerraty 	for (i = 1; i < NSIG; i++) {
354*12904384SSimon J. Gerraty 		if (*mask & sigmask(i)) {
355*12904384SSimon J. Gerraty 			if ((oldh = signal(i, SIG_DFL)) != SIG_ERR &&
356*12904384SSimon J. Gerraty 			    oldh != SIG_IGN &&
357*12904384SSimon J. Gerraty 			    oldh != SIG_DFL)
358*12904384SSimon J. Gerraty 				(void) signal(i, oldh);	/* restore handler */
359*12904384SSimon J. Gerraty 		}
360*12904384SSimon J. Gerraty 	}
361*12904384SSimon J. Gerraty 	pause();		/* wait for a signal */
362*12904384SSimon J. Gerraty #endif
363*12904384SSimon J. Gerraty #endif
364*12904384SSimon J. Gerraty 	return 0;
365*12904384SSimon J. Gerraty }
366*12904384SSimon J. Gerraty #endif
367*12904384SSimon J. Gerraty #endif				/* ! SA_NOCLDSTOP */
368*12904384SSimon J. Gerraty 
369*12904384SSimon J. Gerraty #if 0
370*12904384SSimon J. Gerraty #if !defined(SIG_HDLR)
371*12904384SSimon J. Gerraty #define SIG_HDLR void
372*12904384SSimon J. Gerraty #endif
373*12904384SSimon J. Gerraty #if !defined(SIG_ERR)
374*12904384SSimon J. Gerraty #define SIG_ERR	(SIG_HDLR (*)())-1
375*12904384SSimon J. Gerraty #endif
376*12904384SSimon J. Gerraty 
377*12904384SSimon J. Gerraty #if !defined(USE_SIGNAL) && !defined(USE_SIGMASK) && !defined(NO_SIGNAL)
378*12904384SSimon J. Gerraty /*
379*12904384SSimon J. Gerraty  * ensure we avoid signal mayhem
380*12904384SSimon J. Gerraty  */
381*12904384SSimon J. Gerraty 
382*12904384SSimon J. Gerraty extern void (*Signal (int sig, void (*handler) (int)))(int);
383*12904384SSimon J. Gerraty 
384*12904384SSimon J. Gerraty SIG_HDLR(*signal(int sig, SIG_HDLR(*handler)(int))
385*12904384SSimon J. Gerraty {
386*12904384SSimon J. Gerraty 	return (Signal(sig, handler));
387*12904384SSimon J. Gerraty }
388*12904384SSimon J. Gerraty #endif
389*12904384SSimon J. Gerraty #endif
390*12904384SSimon J. Gerraty 
391*12904384SSimon J. Gerraty /* This lot (for GNU-Emacs) goes at the end of the file. */
392*12904384SSimon J. Gerraty /*
393*12904384SSimon J. Gerraty  * Local Variables:
394*12904384SSimon J. Gerraty  * version-control:t
395*12904384SSimon J. Gerraty  * comment-column:40
396*12904384SSimon J. Gerraty  * End:
397*12904384SSimon J. Gerraty  */
398