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