From 768944672f997895baf074560f74fe6680860486 Mon Sep 17 00:00:00 2001 From: Christian Eggers Date: Wed, 27 Mar 2024 18:30:57 +0100 Subject: [PATCH] posix: pipe_out: fix merge conflict In commit cbaa913e3d73 ("Merge branch 'develop' into limit_fd"), there have been merge conflicts in two files. In pipe_out.hpp, a previous commit from the "limit_fd" branch f8c0dd4da58a ("prototype for limit_fd") had been eliminated during wrong conflict resolution. The final result was, that file descriptors for stdout pipes were not preserved when using limit_handles. Example: boost::asio::io_context io_context; bp::async_pipe my_stdin(io_context); bp::async_pipe my_stdout(io_context); bp::child my_child("/usr/bin/echo", "Hello world", bp::std_in < my_stdin, // preserved by limit_handles bp::std_out > my_stdout, // closed by limit_handles bp::std_err > stderr, // preserved by limit_handles bp::limit_handles) Fixes: cbaa913e3d73 ("Merge branch 'develop' into limit_fd") --- include/boost/process/detail/posix/pipe_out.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/boost/process/detail/posix/pipe_out.hpp b/include/boost/process/detail/posix/pipe_out.hpp index d54cca4ef..19790318d 100644 --- a/include/boost/process/detail/posix/pipe_out.hpp +++ b/include/boost/process/detail/posix/pipe_out.hpp @@ -14,15 +14,25 @@ #include #include #include +#include +#include namespace boost { namespace process { namespace detail { namespace posix { template -struct pipe_out : handler_base_ext +struct pipe_out : handler_base_ext, ::boost::process::detail::uses_handles { int sink; int source; //opposite end + std::array get_used_handles() + { + const auto pp1 = p1 != -1 ? p1 : p2; + const auto pp2 = p2 != -1 ? p2 : p1; + + return {source, sink, pp1, pp2}; + } + pipe_out(int sink, int source) : sink(sink), source(source) {} template