mc_translate.c: enable further uses of DLexpensive for scalar EQ/NE comparisons
[valgrind.git] / none / tests / ppoll_alarm.c
blob1b1794b5e032d874cb96cb97b2c5841637b554e7
1 /* Tries to exploit bug in ppoll mask handling:
2 https://bugs.kde.org/show_bug.cgi?id=359871
3 where client program was able to successfully block VG_SIGVGKILL. */
5 #define _GNU_SOURCE /* for ppoll */
6 #include <poll.h>
7 #include <pthread.h>
8 #include <signal.h>
9 #include <stdio.h>
10 #include <unistd.h>
12 static int ready = 0;
13 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
14 static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
16 static void *
17 mythr(void *ignore)
19 pthread_mutex_lock(&mutex);
20 ready = 1;
21 pthread_cond_signal(&cond);
22 pthread_mutex_unlock(&mutex);
24 sigset_t ss;
25 sigfillset(&ss);
26 while (1) {
27 struct timespec ts = {10000, 0};
28 ppoll(NULL, 0, &ts, &ss);
31 return NULL;
34 int
35 main()
37 pthread_t thr;
38 int ret = pthread_create(&thr, NULL, mythr, NULL);
39 if (ret != 0) {
40 fprintf(stderr, "pthread_create failed\n");
41 return 1;
44 pthread_mutex_lock(&mutex);
45 while (ready == 0) {
46 pthread_cond_wait(&cond, &mutex);
48 pthread_mutex_unlock(&mutex);
50 alarm(1); /* Unhandled SIGALRM should cause exit. */
51 while (1)
52 sleep(1);
54 return 0;