23 lines · cpp
1// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s2#include "test.h"3#include <signal.h>4#include <sys/types.h>5 6static void handler(int, siginfo_t *, void *) {7 write(2, "SIGNAL\n", 7);8 // CHECK: SIGNAL9 _exit(0);10 // CHECK-NOT: ThreadSanitizer: signal-unsafe call11}12 13int main() {14 struct sigaction act = {};15 act.sa_sigaction = &handler;16 act.sa_flags = SA_SIGINFO;17 sigaction(SIGPROF, &act, 0);18 raise(SIGPROF);19 fprintf(stderr, "DONE\n");20 // CHECK-NOT: DONE21 return 0;22}23