Here's a demo adapted from sample here:
You can see it Live on Coliru Sadly that's pushing the limits of Coliru. May be later:
#include <boost/process.hpp>
#include <boost/assign/list_of.hpp>
#include <string>
#include <vector>
#include <iostream>
using namespace boost::process;
int main()
{
std::string exec = find_executable_in_path("rev");
std::vector<std::string> args = boost::assign::list_of("rev");
context ctx;
ctx.environment = self::get_environment();
ctx.stdin_behavior = capture_stream();
ctx.stdout_behavior = capture_stream();
child c = launch(exec, args, ctx);
postream &os = c.get_stdin();
pistream &is = c.get_stdout();
os << "some\ncookies\nfor\ntasting";
os.close();
std::cout << is.rdbuf();
}
Output:
emos
seikooc
rof
gnitsat
Now, if you need it truly asynchronous, there's another sample using Boost Asio further down that page