summaryrefslogtreecommitdiffstats
path: root/contrib/opie/libmissing/sigprocmask.c
blob: 4af1559cbe71ffbe27df586a38e31149523c0cb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* sigprocmask.c: A replacement for the sigprocmask() function

%%% portions-copyright-cmetz
Portions of this software are Copyright 1996 by Craig Metz, All Rights
Reserved. The Inner Net License Version 2 applies to these portions of
the software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.

Portions of this software are Copyright 1995 by Randall Atkinson and Dan
McDonald, All Rights Reserved. All Rights under this copyright are assigned
to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
License Agreement applies to this software.

        History:

	Created by cmetz for OPIE 2.2 from popen.c. Use FUNCTION
               declaration et al. Include opie.h.
*/

#include "opie_cfg.h"

#include <sys/types.h>
#if HAVE_SIGNAL_H
#include <signal.h>
#endif /* HAVE_SIGNAL_H */
#if HAVE_SYS_SIGNAL_H
#include <sys/signal.h>
#endif /* HAVE_SYS_SIGNAL_H */

#if !HAVE_SIGBLOCK || !HAVE_SIGSETMASK
Without sigblock and sigsetmask, we can't build a replacement sigprocmask.
#endif /* !HAVE_SIGBLOCK || !HAVE_SIGSETMASK */

#include "opie.h"

#ifndef sigset_t
#define sigset_t int
#endif /* sigset_t */

int sigprocmask FUNCTION((how, set, oset), int how AND sigset_t *set AND sigset_t *oset)
{
	int old, new;

	if (set && (set != (sigset_t *)SIG_IGN) && (set != (sigset_t *)SIG_ERR))
		new = *set;
	else
		new = 0;

	switch(how) {
		case SIG_BLOCK:
			old = sigblock(new);
			if (oset && (oset != (sigset_t *)SIG_IGN) && (oset != (sigset_t *)SIG_ERR))
				*oset = old;
			return 0;

		case SIG_SETMASK:
                	old = sigsetmask(new);
			if (oset && (oset != (sigset_t *)SIG_IGN) && (oset != (sigset_t *)SIG_ERR))
				*oset = old;
			return 0;

		case SIG_UNBLOCK:
		        /* not implemented */
		default:
			return 0;
	}
}
OpenPOWER on IntegriCloud