1 | // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s |
---|---|
2 | #include <stdio.h> |
3 | #include <stdlib.h> |
4 | #include <signal.h> |
5 | #include <string.h> |
6 | #include <sys/types.h> |
7 | #include <unistd.h> |
8 | |
9 | static void handler(int, siginfo_t*, void*) { |
10 | const char *str = "HELLO FROM SIGNAL\n"; |
11 | write(fd: 2, buf: str, n: strlen(s: str)); |
12 | } |
13 | |
14 | int main() { |
15 | struct sigaction act = {}; |
16 | act.sa_sigaction = &handler; |
17 | sigaction(SIGPROF, act: &act, oact: 0); |
18 | kill(pid: getpid(), SIGPROF); |
19 | sleep(seconds: 1); // let the signal handler run, can't use barrier in sig handler |
20 | fprintf(stderr, format: "DONE\n"); |
21 | return 0; |
22 | } |
23 | |
24 | // CHECK-NOT: WARNING: ThreadSanitizer |
25 | // CHECK: HELLO FROM SIGNAL |
26 | // CHECK: DONE |
27 | |
28 |