Browse Source

Test unshare

test
Michael Uleysky 9 years ago
parent
commit
ab599e2eba
  1. 6
      test/gmttest.cpp

6
test/gmttest.cpp

@ -4,6 +4,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <pthread.h>
#include <sched.h>
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);

Loading…
Cancel
Save