blob: 2b01dd5d1c46778e63ddd5f051f1d2a00707d138 (
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
|
#include <signal.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
// Invokes a process, making sure that the state of the signal
// handlers has all been set back to the unix default.
int main(int argc, char **argv)
{
int i;
sigset_t blockedsigs;
struct sigaction action;
// unblock all signals
sigemptyset(&blockedsigs);
sigprocmask(SIG_BLOCK, NULL, NULL);
// reset all signals to SIG_DFL
memset(&action, 0, sizeof(action));
action.sa_handler = SIG_DFL;
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
for(i = 0; i < NSIG; ++i)
sigaction(i, &action, NULL);
execv(argv[1], argv+1);
fprintf(stderr, "failed to execv %s\n", argv[1]);
return 0;
}
|