From ab599e2eba7cbf35d920d6ab9af80efbcb30c81e Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Tue, 22 Sep 2015 14:14:48 +1000 Subject: [PATCH] Test unshare --- test/gmttest.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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);