aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/pthread_atfork_deadlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/pthread_atfork_deadlock.c')
-rw-r--r--test/tsan/pthread_atfork_deadlock.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/tsan/pthread_atfork_deadlock.c b/test/tsan/pthread_atfork_deadlock.c
index 0f33b9022e5f..4aeec82b6850 100644
--- a/test/tsan/pthread_atfork_deadlock.c
+++ b/test/tsan/pthread_atfork_deadlock.c
@@ -4,14 +4,12 @@
// When the data race was reported, pthread_atfork() handler used to be
// executed which caused another race report in the same thread, which resulted
// in a deadlock.
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
+#include "test.h"
int glob = 0;
void *worker(void *unused) {
- sleep(1);
+ barrier_wait(&barrier);
glob++;
return NULL;
}
@@ -22,10 +20,12 @@ void atfork() {
}
int main() {
+ barrier_init(&barrier, 2);
pthread_atfork(atfork, NULL, NULL);
pthread_t t;
pthread_create(&t, NULL, worker, NULL);
glob++;
+ barrier_wait(&barrier);
pthread_join(t, NULL);
// CHECK: ThreadSanitizer: data race
// CHECK-NOT: ATFORK