Redirecting child process I/O to std::stream

I found out how to do it with Boost, which I'm pretty sure is the closest to a standard-C++ solution you can trivially get.

Create a boost::iostream::file_descriptor_source:
And associate it with a boost::iostreams::stream:

I'm writing a class for managing child processes and I want to be able to write to the child process' inputs (stdin/std::cin) and read its outputs (stdout/std::cout, stderr/std::cerr) from the parent process. The parent process creates unidirectional pipes which the child process redirects STD{IN,OUT,ERR}_FILENO to so that the child process reads from and writes to the pipes, and the parent process writes to and reads from the same pipes, as appropriate.

So, my question is this: how can I expose the pipes as std::{i,o}streams? I want to avoid using/writing a custom wrapper for the streams if possible but I don't think that is possible.
Last edited on
Topic archived. No new replies allowed.