Browse Source

Working(?) version of gmtworkthread

test1
Michael Uleysky 9 years ago
parent
commit
0e5245e901
  1. 15
      test/gmttest.cpp

15
test/gmttest.cpp

@ -24,11 +24,13 @@ void* gmtworkthread(void* x)
struct gmtworkthreadpars* p=reinterpret_cast<struct gmtworkthreadpars*>(x);
char c='\n';
unshare(CLONE_FILES);
dup2(p->fd,1);
write(1,&c,1); // Use this instead of mutex
//unshare(CLONE_FILES);
//dup2(p->fd,1);
//write(p->fd,&c,1);
GMT_Append_Option(p->api,GMT_Make_Option(p->api,'>',const_cast<char*>(("/dev/fd/"+std::to_string(p->fd)).c_str())),reinterpret_cast<struct GMT_OPTION*>(p->opts));
//write(p->fd,&c,1); // Use this instead of mutex
p->ret=GMT_Call_Module(p->api,p->module,GMT_MODULE_OPT,p->opts);
close(1);
//close(1);
close(p->fd);
return 0;
}
@ -63,6 +65,7 @@ int callgmtmodule(void *api, const char *module, void *opts, std::string& res)
return p.ret;
}
int main()
{
char* text="GMT";
@ -75,8 +78,8 @@ int main()
std::string out;
gmtapi=GMT_Create_Session(text,2,0,print_func);
//io=GMT_Register_IO(gmtapi,GMT_IS_TEXTSET,GMT_IS_DUPLICATE,GMT_IS_NONE,GMT_OUT,0,0);
//GMT_Encode_ID(gmtapi,fname,io);
io=GMT_Register_IO(gmtapi,GMT_IS_TEXTSET,GMT_IS_DUPLICATE,GMT_IS_NONE,GMT_OUT,0,0);
GMT_Encode_ID(gmtapi,fname,io);
opts=GMT_Create_Options(gmtapi,0,(void*)args.c_str());
//ret=GMT_Init_IO(gmtapi,GMT_IS_TEXTSET,GMT_IS_NONE,GMT_OUT,5,0,opts);
std::cout<<io<<" "<<GMT_NOTSET<<" "<<fname<<" "<<ret<<std::endl;

Loading…
Cancel
Save