【发布时间】:2017-05-29 09:52:51
【问题描述】:
我正在尝试使用 Boost-1.64.0 调用带有字符串到其标准输入的进程。 当前代码是:
bp::opstream inStream ;
bp::ipstream outStream;
bp::ipstream errStream;
bp::child child(
command, // the command line
bp::shell,
bp::std_out > outStream,
bp::std_err > errStream,
bp::std_in < inStream);
// read the outStream/errStream in threads
child.wait();
问题在于子可执行文件正在等待其标准输入 EOF。这里 child.wait() 无限期挂起......
我尝试使用 asio::buffer、std_in.close()、……但没有运气。 我发现的唯一 hack 是 delete() inStream……这并不可靠。
我应该如何“通知”子进程并使用新的 boost::process 库关闭其标准输入?
谢谢!
【问题讨论】:
-
什么意思,"delete() inStream"?这对我来说没有多大意义。
标签: c++ boost stdin boost-process