Skip to content

Commit

Permalink
posix: Fix pipe fd leak if redirecting both stdout and stderr
Browse files Browse the repository at this point in the history
This re-adds the close(source) call which already existed here before
commit caa7b2f. pipe_out already closes the source fd when redirecting
stdout or stderr, it was just missing when redirecting both at once.

The pipe fds must be closed after redirecting to avoid keeping the pipe
open unnecessarily, for example the parent may want to close their end of
the pipe.

Closes: #353
Signed-off-by: Daniel Klauer <[email protected]>
  • Loading branch information
dkl authored and klemens-morgenstern committed Jun 4, 2024
1 parent 20510ab commit e8b5bf1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions include/boost/process/detail/posix/pipe_out.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void pipe_out<1,2>::on_exec_setup(Executor &e) const
e.set_error(::boost::process::detail::get_last_error(), "dup2() failed");
if ((sink != STDOUT_FILENO) && (sink != STDERR_FILENO))
::close(sink);
::close(source);
}

class async_pipe;
Expand Down

0 comments on commit e8b5bf1

Please sign in to comment.