Like the title says, I want to co_await for a process spawned with boost::process::async_system.
So I'm doing something like this:
namespace bp = boost::process;
bp::async_pipe ap(io_);
// Create the child process object with our parameters and a redirected stdout
co_await bp::async_system(io_,
boost::asio::use_awaitable,
bp::search_path(command),
bp::start_dir(cwd),
bp::args(args),
bp::std_out > ap);
But I'm getting a very unhelpful error-message.
My assumption now is, that async_system is not compatible with co_await. Is there another (maybe generic) way to integrate 3rd party async mechanisms in boost::asio::awaitable?
(I feel a bit lost in this whole boost::asio / c++ coro topic. Google is not very helpful and the boost doc a bit too minimalistic for me.)
I'd mold the code a bit for style: http://coliru.stacked-crooked.com/a/33667a7d106de0e7
The Real Problem
Now with the above, there's is still an error inside
my_corowhen you try to uncomment theasync_systemcall.Instead of reading the message, I looked at the code, figured that it should have worked, and looked at the implementation:
After looking at the implementation, I figured that
indicates that Boost Process has not been updated to support newer
async_resultprotocol, which instead ofcompletion_handler_typeappears to use theinitiatemember function. This gives the async_result implementation more options, which are probably required foruse_awaitable_ttokens.I'd raise an issue at the library.
Note that current
developbranch has code underway that does seem to correctly support use_awaitable (e.v.boost/process/v2/popen.hpp)