mirror of
https://github.com/boostorg/process.git
synced 2026-01-20 04:42:24 +00:00
Compare commits
3 Commits
master
...
klemens-mo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cb7af6c8b | ||
|
|
df33c1ad7b | ||
|
|
bbabea30dd |
@@ -444,6 +444,8 @@ child executor<Sequence>::invoke(boost::mpl::false_, boost::mpl::false_)
|
||||
}
|
||||
if (_ec)
|
||||
{
|
||||
//if an error occured we need to reap the child process
|
||||
::waitpid(this->pid, nullptr, WNOHANG);
|
||||
boost::fusion::for_each(seq, call_on_error(*this, _ec));
|
||||
return child();
|
||||
}
|
||||
@@ -537,6 +539,7 @@ child executor<Sequence>::invoke(boost::mpl::false_, boost::mpl::true_)
|
||||
|
||||
if (_ec)
|
||||
{
|
||||
::waitpid(this->pid, nullptr, WNOHANG);
|
||||
boost::fusion::for_each(seq, call_on_error(*this, _ec));
|
||||
return child();
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
auto st1 = key + ::boost::process::detail::equal_sign<Char>();
|
||||
while (*p != nullptr)
|
||||
{
|
||||
const int len = std::char_traits<Char>::length(*p);
|
||||
const auto len = std::char_traits<Char>::length(*p);
|
||||
if ((std::distance(st1.begin(), st1.end()) < len)
|
||||
&& std::equal(st1.begin(), st1.end(), *p))
|
||||
break;
|
||||
|
||||
@@ -91,13 +91,16 @@ struct bind_fd
|
||||
{
|
||||
}
|
||||
|
||||
error_code on_setup(posix::default_launcher & launcher, const filesystem::path &, const char * const *)
|
||||
{
|
||||
launcher.fd_whitelist.push_back(target);
|
||||
}
|
||||
|
||||
/// Implementation of the initialization function.
|
||||
error_code on_exec_setup(posix::default_launcher & launcher, const filesystem::path &, const char * const *)
|
||||
{
|
||||
if (::dup2(fd, target) == -1)
|
||||
return error_code(errno, system_category());
|
||||
|
||||
launcher.fd_whitelist.push_back(target);
|
||||
return error_code ();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -378,6 +378,7 @@ struct default_launcher
|
||||
detail::on_error(*this, executable, argv, ec, inits...);
|
||||
return basic_process<Executor>(exec);
|
||||
}
|
||||
fd_whitelist.push_back(pg.p[1]);
|
||||
|
||||
auto & ctx = BOOST_PROCESS_V2_ASIO_NAMESPACE::query(
|
||||
exec, BOOST_PROCESS_V2_ASIO_NAMESPACE::execution::context);
|
||||
@@ -399,7 +400,6 @@ struct default_launcher
|
||||
ec = detail::on_exec_setup(*this, executable, argv, inits...);
|
||||
if (!ec)
|
||||
{
|
||||
fd_whitelist.push_back(pg.p[1]);
|
||||
close_all_fds(ec);
|
||||
}
|
||||
if (!ec)
|
||||
|
||||
@@ -99,6 +99,7 @@ struct pdfork_launcher : default_launcher
|
||||
detail::on_error(*this, executable, argv, ec, inits...);
|
||||
return basic_process<Executor>(exec);
|
||||
}
|
||||
fd_whitelist.push_back(pg.p[1]);
|
||||
|
||||
auto & ctx = BOOST_PROCESS_V2_ASIO_NAMESPACE::query(
|
||||
exec, BOOST_PROCESS_V2_ASIO_NAMESPACE::execution::context);
|
||||
@@ -121,7 +122,6 @@ struct pdfork_launcher : default_launcher
|
||||
ec = detail::on_exec_setup(*this, executable, argv, inits...);
|
||||
if (!ec)
|
||||
{
|
||||
fd_whitelist.push_back(pg.p[1]);
|
||||
close_all_fds(ec);
|
||||
}
|
||||
if (!ec)
|
||||
|
||||
@@ -289,11 +289,6 @@ struct process_stdio
|
||||
if (::dup2(err.fd, err.target) == -1)
|
||||
return error_code(errno, system_category());
|
||||
|
||||
|
||||
launcher.fd_whitelist.push_back(STDIN_FILENO);
|
||||
launcher.fd_whitelist.push_back(STDOUT_FILENO);
|
||||
launcher.fd_whitelist.push_back(STDERR_FILENO);
|
||||
|
||||
return error_code {};
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -113,3 +113,17 @@ BOOST_AUTO_TEST_CASE(ignore_error)
|
||||
BOOST_CHECK_NO_THROW(bp::child c("doesnt-exit", bp::ignore_error));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(not_found)
|
||||
{
|
||||
try
|
||||
{
|
||||
bp::child c("doesnt-exit");
|
||||
BOOST_CHECK_MESSAGE(false, "Should throw");
|
||||
}
|
||||
catch( bp::process_error & se)
|
||||
{
|
||||
BOOST_CHECK(se.code());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user