1 // RUN: %clangxx_tsan %s -o %t && %run %t 2>&1 | FileCheck %s
12 volatile bool signal_delivered
;
14 static void handler(int sig
) {
16 signal_delivered
= true;
19 static void* thr(void *p
) {
22 sigaddset(&sigset
, SIGALRM
);
23 int ret
= pthread_sigmask(SIG_UNBLOCK
, &sigset
, NULL
);
26 struct sigaction act
= {};
27 act
.sa_handler
= &handler
;
28 if (sigaction(SIGALRM
, &act
, 0)) {
34 t
.it_value
.tv_sec
= 0;
35 t
.it_value
.tv_usec
= 10000;
36 t
.it_interval
= t
.it_value
;
37 if (setitimer(ITIMER_REAL
, &t
, 0)) {
42 while (!signal_delivered
) {
46 t
.it_value
.tv_usec
= 0;
47 if (setitimer(ITIMER_REAL
, &t
, 0)) {
52 fprintf(stderr
, "SIGNAL DELIVERED\n");
60 sigaddset(&sigset
, SIGALRM
);
61 int ret
= pthread_sigmask(SIG_BLOCK
, &sigset
, NULL
);
65 pthread_create(&th
, 0, thr
, 0);
68 fprintf(stderr
, "DONE\n");
72 // CHECK-NOT: WARNING: ThreadSanitizer:
73 // CHECK: SIGNAL DELIVERED
75 // CHECK-NOT: WARNING: ThreadSanitizer: