
On Fri, 10 Sep 2010 03:33:53 +0400 Ilya Sokolov <ilyasokol@gmail.com> wrote:
[snip]
class redirect_to { fileno to_; public:
redirect_to(fileno to): to_(to) {} std::pair<handle, handle> operator()(fileno fn, const child_streams& cs) { BOOST_ASSERT(fn > to_); #ifndef _WIN32 handle child_end(posix_dup2(to_, fn)); #else // ... #endif handle parent_end; return std::make_pair(child_end, parent_end); } };
Not sure who wrote that code ;-) I should stop posting at night. class redirect_to { fileno to_; public: redirect_to(fileno to): to_(to) {} std::pair<handle, handle> operator()(fileno fn, const child_streams& cs) { BOOST_ASSERT(fn > to_); child_streams::const_iterator it = // find pair in cs where it->first == to_ #ifndef _WIN32 handle child_end(posix_dup2(it->second, fn)); #else // ... #endif handle parent_end; return std::make_pair(child_end, parent_end); } };