You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include <gmt.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
int print_func(FILE* fd, const char* str)
|
|
|
|
{
|
|
|
|
std::cout<<"PRINT: "<<str<<std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* thr(void* p)
|
|
|
|
{
|
|
|
|
std::cout<<"Thread Phase1\n";
|
|
|
|
close(1);
|
|
|
|
std::cout<<"Thread Phase2\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int savefd;
|
|
|
|
pthread_t t;
|
|
|
|
|
|
|
|
std::cout<<"Phase1\n";
|
|
|
|
savefd=dup(1);
|
|
|
|
pthread_create(&t,0,&thr,0);
|
|
|
|
pthread_join(t,0);
|
|
|
|
std::cout<<"Phase2\n";
|
|
|
|
dup2(savefd,1);
|
|
|
|
std::cout<<"Phase3\n";
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|