From 0e5245e9015e725a63da000d8ca56c697ea3373f Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Tue, 22 Sep 2015 21:47:02 +1000 Subject: [PATCH] Working(?) version of gmtworkthread --- test/gmttest.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/gmttest.cpp b/test/gmttest.cpp index a9a9f78..dcdd18a 100644 --- a/test/gmttest.cpp +++ b/test/gmttest.cpp @@ -24,11 +24,13 @@ void* gmtworkthread(void* x) struct gmtworkthreadpars* p=reinterpret_cast(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(("/dev/fd/"+std::to_string(p->fd)).c_str())),reinterpret_cast(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<