Boost logo

Boost :

Subject: Re: [boost] [gsoc] Boost.Process done
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2010-10-29 14:30:26

Hello Boris,

To portably use boost::process::behavior::inherit, it should call in
it's constructor:

#if defined(BOOST_WINDOWS_API)
     if (!SetHandleInformation( h_.native()
                              , HANDLE_FLAG_INHERIT
                              , HANDLE_FLAG_INHERIT))
      "SetHandleInformation() failed");

Otherwise the following use case fails on Windows to redirect output to
a file:

void inherit_test
(std::string exe, const args& a, std::string out, std::string err)
   boost::iostreams::file_descriptor_sink stdOutFile;
   boost::iostreams::file_descriptor_sink stdErrFile;
   boost::process::context ctx;

   if (!out.empty())
     = boost::process::behavior::inherit(stdOutFile.handle());

   if (!standardErrorFile.empty())
     = boost::process::behavior::inherit(stdErrFile.handle());

   boost::process::child c = boost::process::create_child(exe, a, ctx);



Boost list run by bdawes at, gregod at, cpdaniel at, john at