1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
13 void *Thread1(void *x
) {
15 write(fds
[1], "a", 1);
19 void *Thread2(void *x
) {
21 while (read(fds
[0], &buf
, 1) != 1) {
31 fprintf(stderr
, "FAIL to vfork\n");
34 if (pid
== 0) { // child
35 // Closing of fds must not affect parent process.
36 // Strictly saying this is undefined behavior, because vfork child is not
37 // allowed to call any functions other than exec/exit. But this is what
44 pthread_create(&t
[0], NULL
, Thread1
, NULL
);
45 pthread_create(&t
[1], NULL
, Thread2
, NULL
);
46 pthread_join(t
[0], NULL
);
47 pthread_join(t
[1], NULL
);
48 fprintf(stderr
, "DONE\n");
51 // CHECK-NOT: WARNING: ThreadSanitizer: data race
52 // CHECK-NOT: FAIL to vfork