diff --git a/test/gmttest.cpp b/test/gmttest.cpp index 1dbe498..63aedef 100644 --- a/test/gmttest.cpp +++ b/test/gmttest.cpp @@ -4,6 +4,7 @@ #include #include #include +#include int print_func(FILE* fd, const char* str) { @@ -15,7 +16,10 @@ void* thr(void* p) { std::cout<<"Thread Phase1\n"; close(1); + unshare(CLONE_FILES); std::cout<<"Thread Phase2\n"; + dup2(*(int*)p,1); + std::cout<<"Thread Phase3\n"; return 0; } @@ -27,7 +31,7 @@ int main() std::cout<<"Phase1\n"; savefd=dup(1); - pthread_create(&t,0,&thr,0); + pthread_create(&t,0,&thr,&savefd); pthread_join(t,0); std::cout<<"Phase2\n"; dup2(savefd,1);