Home | History | Annotate | Download | only in TestCases
      1 // Test that thread local data is handled correctly after forking without exec().
      2 // RUN: %clangxx_lsan %s -o %t
      3 // RUN: %run %t 2>&1
      4 
      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 
     13 int 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