1254219Scy/*-
2254219Scy * Copyright (c) 2015 Antti Kantee.  All Rights Reserved.
3254219Scy *
4254219Scy * Redistribution and use in source and binary forms, with or without
5254219Scy * modification, are permitted provided that the following conditions
6254219Scy * are met:
7254219Scy * 1. Redistributions of source code must retain the above copyright
8254219Scy *    notice, this list of conditions and the following disclaimer.
9254219Scy * 2. Redistributions in binary form must reproduce the above copyright
10254219Scy *    notice, this list of conditions and the following disclaimer in the
11254219Scy *    documentation and/or other materials provided with the distribution.
12254219Scy *
13254219Scy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
14254219Scy * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15254219Scy * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16254219Scy * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17254219Scy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18254219Scy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19254219Scy * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20254219Scy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21254219Scy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22254219Scy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23254219Scy * SUCH DAMAGE.
24254219Scy */
25254219Scy
26254219Scy/*
27254219Scy * Our signal strategy: these calls always return success so that
28254219Scy * applications do not panic, but we never deliver signals.
29254219Scy */
30254219Scy
31254219Scy#include <sys/cdefs.h>
32254219Scy#include <sys/types.h>
33254219Scy
34254219Scy#include <errno.h>
35254219Scy#include <stdio.h>
36254219Scy#include <signal.h>
37254219Scy#include <string.h>
38254219Scy
39254219Scy#define STUBWARN()							\
40254219Scydo {									\
41254219Scy  if (!warned) {							\
42254219Scy	warned = 1;							\
43	fprintf(stderr, "rumprun: call to ``%s'' ignored\n",		\
44	    __FUNCTION__);						\
45  }									\
46} while (/*CONSTCOND*/0)
47
48int
49sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
50{
51	static int warned = 0;
52
53	if (act && (act->sa_flags & SA_SIGINFO || act->sa_handler != SIG_IGN)) {
54		STUBWARN();
55	}
56
57	/* should probably track contents, maybe later */
58	if (oact) {
59		memset(oact, 0, sizeof(*oact));
60		oact->sa_handler = SIG_IGN;
61	}
62	return 0;
63}
64__strong_alias(sigaction,__sigaction14);
65
66int _sys___sigprocmask14(int, const sigset_t *, sigset_t *); /* XXX */
67int
68_sys___sigprocmask14(int how, const sigset_t *set, sigset_t *oset)
69{
70	static int warned = 0;
71
72	STUBWARN();
73
74	/* should probably track contents, maybe later */
75	if (oset)
76		memset(oset, 0, sizeof(*oset));
77	return 0;
78}
79__strong_alias(sigprocmask,__sigprocmask14);
80__weak_alias(__sigprocmask14,_sys___sigprocmask14);
81
82int
83sigpending(sigset_t *set)
84{
85	static int warned = 0;
86
87	STUBWARN();
88
89	if (set)
90		memset(set, 0, sizeof(*set));
91	return 0;
92}
93__strong_alias(sigpending,__sigpending14);
94
95int
96sigqueueinfo(pid_t pid, const siginfo_t *info)
97{
98	static int warned = 0;
99
100	STUBWARN();
101
102	errno = EPERM;
103	return -1;
104}
105