所以我尝试用Boost.Process做一些事情,尽管它还没有被 Boost 发行版接受。
最简单的程序看起来像
#include <boost/process.hpp>
#include <string>
#include <vector>
namespace bp = ::boost::process;
void Hello()
{
//... contents does not matter for me now - I just want to make a new process running this function using Boost.Process.
}
bp::child start_child()
{
std::string exec = "bjam";
std::vector<std::string> args;
args.push_back("--version");
bp::context ctx;
ctx.stdout_behavior = bp::silence_stream();
return bp::launch(exec, args, ctx);
}
int main()
{
bp::child c = start_child();
bp::status s = c.wait();
return s.exited() ? s.exit_status() : EXIT_FAILURE;
}
如何提高我正在创建的执行 Hello() 函数的进程?