brintos

brintos / llvm-project-archived public Read only

0
0
Text · 507 B · 9e72fe8 Raw
25 lines · cpp
1// Test that thread local data is handled correctly after forking without exec().2// RUN: %clangxx_lsan %s -o %t3// RUN: %run %t 2>&14 5#include <assert.h>6#include <stdio.h>7#include <stdlib.h>8#include <sys/wait.h>9#include <unistd.h>10 11__thread void *thread_local_var;12 13int main() {14  int status = 0;15  thread_local_var = malloc(1337);16  pid_t pid = fork();17  assert(pid >= 0);18  if (pid > 0) {19    waitpid(pid, &status, 0);20    assert(WIFEXITED(status));21    return WEXITSTATUS(status);22  }23  return 0;24}25