xen: syswrap XEN_DOMCTL_pin_mem_cacheattr
[valgrind.git] / gdbserver_tests / passsigalrm.c
blob14f6095e942bac1865ee86e22a2e3b9cd3102564
1 #include <stdio.h>
2 #include <signal.h>
3 #include <unistd.h>
4 #include <stdlib.h>
6 static int sigalrm_received = 0;
7 static void sigalrm_handler(int signr)
9 sigalrm_received++;
11 static int sigrtmin_received = 0;
12 static void sigrtmin_handler(int signr)
14 sigrtmin_received++;
17 static int breakme = 0;
18 #ifndef SIGRTMIN
19 // at least on MacOS, there is no SIGRTMIN.
20 // So, use any other signal instead.
21 #define SIGRTMIN SIGUSR1
22 #endif
24 int main (int argc, char *argv[])
26 struct sigaction sa;
27 fprintf(stderr, "starting ...\n");
28 sa.sa_handler = sigalrm_handler;
29 sigemptyset(&sa.sa_mask);
30 sa.sa_flags = 0;
32 if (sigaction (SIGALRM, &sa, NULL) != 0)
33 perror("sigaction");
34 if (kill(getpid(), SIGALRM) != 0)
35 perror("kill 1");
37 if (sigalrm_received == 1)
38 fprintf (stderr, "ok: 1st SIGALRM received\n");
39 else
40 fprintf (stderr, "wrong 1st: unexpected value %d sigalrm_received\n",
41 sigalrm_received);
43 if (kill(getpid(), SIGALRM) != 0)
44 perror("kill 2");
46 if (sigalrm_received == 2)
47 fprintf (stderr, "ok: 2nd SIGALRM received\n");
48 else
49 fprintf (stderr, "wrong 2nd: unexpected value %d sigalrm_received\n",
50 sigalrm_received);
52 system("../tests/true");
53 breakme++;
55 sa.sa_handler = sigrtmin_handler;
56 sigemptyset(&sa.sa_mask);
57 sa.sa_flags = 0;
59 if (sigaction (SIGRTMIN, &sa, NULL) != 0)
60 perror("sigaction");
61 if (kill(getpid(), SIGRTMIN) != 0)
62 perror("kill sigrtmin");
63 if (sigrtmin_received == 1)
64 fprintf (stderr, "ok: SIGRTMIN received\n");
65 else
66 fprintf (stderr, "wrong sigrtmin: unexpected value %d sigrtmin_received\n",
67 sigrtmin_received);
68 return 0;