Redirecting child process I/O to std::stream

[edit]
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: http://www.boost.org/doc/libs/1_42_0/libs/iostreams/doc/classes/file_descriptor.html
And associate it with a boost::iostreams::stream: http://www.boost.org/doc/libs/1_42_0/libs/iostreams/doc/guide/generic_streams.html#stream
[/edit]

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.