1// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2#include "test.h"
3#include <sys/types.h>
4#include <unistd.h>
5
6// Setuid call used to hang because the background tsan thread did not handle
7// SIGSETXID signal. Note that we don't care whether setuid call succeeds
8// or not.
9
10static void *thread(void *arg) {
11  (void)arg;
12  sleep(1);
13  return 0;
14}
15
16int main() {
17  // Create another thread just for completeness of the picture.
18  pthread_t th;
19  pthread_create(&th, 0, thread, 0);
20  setuid(0);
21  pthread_join(th, 0);
22  fprintf(stderr, "DONE\n");
23  return 0;
24}
25
26// CHECK: DONE
27