我知道有一种 boost::process::child 的方法,如下所述:
boost::asio::boost::asio::io_service ios;
std::future<std::string> data;
child c("g++", "main.cpp", //set the input
bp::std_in.close(),
bp::std_out > bp::null, //so it can be written without anything
bp::std_err > data,
ios);
ios.run(); //this will actually block until the compiler is finished
auto err = data.get();
这可以在调用 boost::process::spawn 时工作还是我必须使用 boost::process::child 来这样做?