static bool spawnSelfTestOneProcess(const std::string &path) { std::cout << "Testing " << path << "... " << std::flush; const int success = 200; //create args Poco::Process::Args args; args.push_back("--self-test1"); args.push_back(path); args.push_back("--success-code"); args.push_back(std::to_string(success)); //launch Poco::Process::Env env; Poco::Pipe outPipe; //no fwd stdio Poco::ProcessHandle ph(Poco::Process::launch( Pothos::System::getPothosUtilExecutablePath(), args, nullptr, &outPipe, &outPipe, env)); std::future<std::string> verboseFuture(std::async(std::launch::async, &collectVerbose, outPipe)); const bool ok = (ph.wait() == success); std::cout << ((ok)? "success!" : "FAIL!") << std::endl; outPipe.close(); verboseFuture.wait(); if (not ok) std::cout << verboseFuture.get(); return ok; }
void Download (const std::string &url, std::string *file) { Poco::Pipe inPipe; std::vector<std::string> args; args.push_back("--output-document=-"); args.push_back("--tries=1"); args.push_back(url); Poco::ProcessHandle sub(Poco::Process::launch("wget", args, 0, &inPipe, 0)); Poco::PipeInputStream input(inPipe); Poco::StreamCopier::copyToString(input, *file); inPipe.close(Poco::Pipe::CLOSE_READ); sub.wait(); }