【发布时间】:2017-08-31 08:21:22
【问题描述】:
我正在玩弄 boost 进程库。但由于某些原因,我无法向标准输入发送内容:
#include <iostream>
#include <boost/process.hpp>
using namespace boost::process;
int main(int argc, char** argv) {
boost::asio::io_service ios;
std::future<std::string> outdata;
std::future<std::string> errdata;
child c("/usr/bin/cat",
std_out > outdata,
std_err > errdata,
std_in < "hi, there!", ios);
ios.run();
std::cout << "stdout: " << outdata.get() << std::endl;
std::cerr << "stderr: " << errdata.get() << std::endl;
}
我希望这基本上可以像
echo "hi, there" | cat
但是输出是空的。我错过了什么?
【问题讨论】:
标签: c++ boost process boost-asio