#include #include #include #include #include int print_func(FILE* fd, const char* str) { std::cout<<"PRINT: "<(x); char c='\n'; //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(p->fd); return 0; } int callgmtmodule(void *api, const char *module, void *opts, std::string& res) { int pipefd[2]; ssize_t br; char buffer[4096]; pthread_t wthr; struct gmtworkthreadpars p; pipe(pipefd); p.api=api; p.module=module; p.opts=opts; p.fd=pipefd[1]; pthread_create(&wthr,0,&gmtworkthread,&p); res.erase(); read(pipefd[0],buffer,1); close(pipefd[1]); do { br=read(pipefd[0],buffer,4096); std::cout<