brintos

brintos / llvm-project-archived public Read only

0
0
Text · 644 B · edb3d23 Raw
28 lines · cpp
1// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s2#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 handler20  fprintf(stderr, "DONE\n");21  return 0;22}23 24// CHECK-NOT: WARNING: ThreadSanitizer25// CHECK: HELLO FROM SIGNAL26// CHECK: DONE27 28