Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Commit

Permalink
remove ill-formed test & minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
klemens-morgenstern committed May 14, 2019
1 parent 519c0a6 commit e426f2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions include/boost/process/detail/posix/handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ inline std::vector<native_handle_type> get_handles(std::error_code & ec)
{
std::vector<native_handle_type> res;

std::unique_ptr<DIR, decltype(&::closedir)> dir{
::opendir("/dev/fd"),
&::closedir};
std::unique_ptr<DIR, void(*)(DIR*)> dir{::opendir("/dev/fd"), +[](DIR* p){::closedir(p);}};
if (!dir)
{
ec = ::boost::process::detail::get_last_error();
Expand Down
4 changes: 3 additions & 1 deletion include/boost/process/detail/posix/pipe_in.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ struct pipe_in : handler_base_ext, ::boost::process::detail::uses_handles
{
if (::dup2(source, STDIN_FILENO) == -1)
e.set_error(::boost::process::detail::get_last_error(), "dup2() failed");
::close(source);
if (source != STDIN_FILENO)
::close(source);

::close(sink);
}

Expand Down
10 changes: 4 additions & 6 deletions test/limit_fd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,15 @@ BOOST_AUTO_TEST_CASE(iterate_handles, *boost::unit_test::timeout(5))
BOOST_WARN_NE(source, sink); //Sanity check

const auto ret = bp::system(master_test_suite().argv[1], "--exit-code" , "42",
bp::std_in < p_in,
bp::std_out > p_out,
bp::std_in < p_out,
bp::std_out > p_in,
bp::extend::on_setup(on_setup_t(res)), ec);

BOOST_CHECK_MESSAGE(!ec, ec.message());

BOOST_CHECK_EQUAL(ret, 42);
BOOST_CHECK_GE(std::count(res.begin(), res.end(), source), 1);
BOOST_CHECK_GE(std::count(res.begin(), res.end(), sink ), 1);
BOOST_CHECK_GE(std::count(res.begin(), res.end(), p_in. native_sink()), 0);
BOOST_CHECK_GE(std::count(res.begin(), res.end(), p_out.native_source()), 0);
BOOST_CHECK_EQUAL(std::count(res.begin(), res.end(), p_in. native_sink()), 0);
BOOST_CHECK_EQUAL(std::count(res.begin(), res.end(), p_out.native_source()), 0);
}

BOOST_AUTO_TEST_CASE(limit_fd, *boost::unit_test::timeout(5))
Expand Down

0 comments on commit e426f2b

Please sign in to comment.