summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts/exec_signals_prepare.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/rts/exec_signals_prepare.c')
-rw-r--r--testsuite/tests/rts/exec_signals_prepare.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/rts/exec_signals_prepare.c b/testsuite/tests/rts/exec_signals_prepare.c
new file mode 100644
index 0000000000..26f30acc57
--- /dev/null
+++ b/testsuite/tests/rts/exec_signals_prepare.c
@@ -0,0 +1,29 @@
+#include <signal.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.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;
+}