#include <boost/process.hpp> 
#include <boost/assign/list_of.hpp> 
#include <string> 
#include <vector> 
#include <iostream> 
#include <unistd.h> 
#include <sys/types.h> 

using namespace boost::process; 

int main() 
{ 
  std::string exec = find_executable_in_path("dbus-daemon"); 
  std::vector<std::string> args = boost::assign::list_of("dbus-daemon") 
    ("--session")("--fork")("--print-address=3")("--print-pid=4"); 
  posix_context ctx; 
  ctx.output_behavior.insert(behavior_map::value_type(STDOUT_FILENO, inherit_stream())); 
  ctx.output_behavior.insert(behavior_map::value_type(STDERR_FILENO, inherit_stream())); 
  ctx.output_behavior.insert(behavior_map::value_type(3, capture_stream())); 
  ctx.output_behavior.insert(behavior_map::value_type(4, capture_stream())); 
  ctx.environment = self::get_environment(); 
  posix_child c = posix_launch(exec, args, ctx); 
  std::string address; 
  pid_t pid; 
  c.get_output(3) >> address; 
  c.get_output(4) >> pid; 
  std::cout << "Address: " << address << "\nPID: " << pid << std::endl; 
} 