signal_write.cc revision 86277eb844c4983c81de62d7c050e92fe7155788
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 9static void handler(int, siginfo_t*, void*) { 10 const char *str = "HELLO FROM SIGNAL\n"; 11 write(2, str, strlen(str)); 12} 13 14int main() { 15 struct sigaction act = {}; 16 act.sa_sigaction = &handler; 17 sigaction(SIGPROF, &act, 0); 18 kill(getpid(), SIGPROF); 19 sleep(1); // let the signal handler run, can't use barrier in sig handler 20 fprintf(stderr, "DONE\n"); 21 return 0; 22} 23 24// CHECK-NOT: WARNING: ThreadSanitizer 25// CHECK: HELLO FROM SIGNAL 26// CHECK: DONE 27 28