#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(1,&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<