-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsignal.c
69 lines (59 loc) · 1.62 KB
/
signal.c
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
69
#include <signal.h>
#include <unistd.h>
#include "dbg.h"
#include "preload.h"
static int sig_ignore;
int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
static int (*orig_sigaction)(int, const struct sigaction*,
struct sigaction*);
ASSIGN(sigaction);
dbg("%s(sig=%d)\n", __func__, sig);
return sig_ignore ? 0 : orig_sigaction(sig, act, oact);
}
int sigaddset(sigset_t *set, int signo)
{
static int (*orig_sigaddset)(sigset_t *set, int signo);
ASSIGN(sigaddset);
/* dbg("%s(signo=%d)\n", __func__, signo); */
return orig_sigaddset(set, signo);
}
int sigdelset(sigset_t *set, int signo)
{
static int (*orig_sigdelset)(sigset_t *set, int signo);
ASSIGN(sigdelset);
/* dbg("%s(signo=%d)\n", __func__, signo); */
return orig_sigdelset(set, signo);
}
int sigemptyset(sigset_t *set)
{
static int (*orig_sigemptyset)(sigset_t *set);
ASSIGN(sigemptyset);
/* dbg("%s\n", __func__); */
return orig_sigemptyset(set);
}
int sigismember(const sigset_t *set, int signo)
{
static int (*orig_sigismember)(const sigset_t *set, int signo);
ASSIGN(sigismember);
/* dbg("%s(signo=%d)\n", __func__, signo); */
return orig_sigismember(set, signo);
}
sighandler_t signal(int sig, sighandler_t handler)
{
static sighandler_t (*orig_signal)(int sig, sighandler_t handler);
ASSIGN(signal);
dbg("%s(sig=%d)\n", __func__, sig);
return sig_ignore ? 0 : orig_signal(sig, handler);
}
unsigned int sleep(unsigned int seconds)
{
static unsigned int (*orig_sleep)(unsigned int seconds);
ASSIGN(sleep);
dbg("%s(seconds=%d)\n", __func__, seconds);
return orig_sleep(seconds);
}
void signal_ignore_all(void)
{
sig_ignore = 1;
}