aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt@console-pimps.org>2011-08-08 10:25:49 +0200
committermaximilian attems <max@stro.at>2011-08-16 20:33:37 +0200
commiteee0fa5c2f3f1c9f4c0d3a3cf66ea5d5aff6aa80 (patch)
tree1c214581d81708234a844023c39d7a0ec0aee98c
parent201dabf78546ca712d3541670a5d898dc199854e (diff)
downloadklibc-eee0fa5c2f3f1c9f4c0d3a3cf66ea5d5aff6aa80.tar.gz
[klibc] test: Add signal nodefer
Uncovered a bug in avr32 signal handling, might come handy in testing other archs signal. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/klibc/tests/Kbuild1
-rw-r--r--usr/klibc/tests/sig-nodefer.c55
2 files changed, 56 insertions, 0 deletions
diff --git a/usr/klibc/tests/Kbuild b/usr/klibc/tests/Kbuild
index a3e0254c5685d..b7978d47b734a 100644
--- a/usr/klibc/tests/Kbuild
+++ b/usr/klibc/tests/Kbuild
@@ -35,6 +35,7 @@ select.shared-y := select.o
setenvtest.shared-y := setenvtest.o
setjmptest.shared-y := setjmptest.o
sigint.shared-y := sigint.o
+sig-nodefer.shared-y := sig-nodefer.o
socket.shared-y := socket.o
stat.shared-y := stat.o
statfs.shared-y := statfs.o
diff --git a/usr/klibc/tests/sig-nodefer.c b/usr/klibc/tests/sig-nodefer.c
new file mode 100644
index 0000000000000..e988806d1e688
--- /dev/null
+++ b/usr/klibc/tests/sig-nodefer.c
@@ -0,0 +1,55 @@
+/*
+ * Expected output of ./sig-defer:
+ * SIGUSR2: blocked
+ * SIGTERM: blocked
+ */
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+void handler(int signum)
+{
+ sigset_t mask;
+
+ sigprocmask(SIG_BLOCK, NULL, &mask);
+ printf("SIGUSR2: %s\n",
+ sigismember(&mask, SIGUSR2) ? "blocked" : "not blocked");
+ printf("SIGTERM: %s\n",
+ sigismember(&mask, SIGTERM) ? "blocked" : "not blocked");
+}
+
+int main(int argc, char **argv)
+{
+ pid_t pid;
+
+ pid = fork();
+ if (pid == -1) {
+ perror("fork");
+ exit(EXIT_FAILURE);
+ } else if (!pid) {
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ act.sa_handler = handler;
+ act.sa_flags = SA_NODEFER;
+
+ sigaddset(&act.sa_mask, SIGUSR2);
+ sigaddset(&act.sa_mask, SIGTERM);
+
+ sigaction(SIGUSR1, &act, NULL);
+
+ pause();
+ } else {
+ int status;
+
+ sleep(3);
+ kill(pid, SIGUSR1);
+ waitpid(pid, &status, 0);
+ }
+
+ return 0;
+}