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