Merge branch 'develop' into limit_fd

This commit is contained in:
Klemens David Morgenstern 2019-05-07 12:16:53 +07:00
commit 6263e74bcd
3 changed files with 11 additions and 8 deletions

View File

@ -145,11 +145,12 @@ public:
bool running(std::error_code & ec) noexcept
{
if (valid() && !_exited())
ec.clear();
if (valid() && !_exited() && !ec)
{
int exit_code = 0;
auto res = boost::process::detail::api::is_running(_child_handle, exit_code, ec);
if (!res && !_exited())
if (!ec && !res && !_exited())
_exit_status->store(exit_code);
return res;
@ -159,10 +160,11 @@ public:
void terminate(std::error_code & ec) noexcept
{
if (valid() && running(ec))
if (valid() && running(ec) && !ec)
boost::process::detail::api::terminate(_child_handle, ec);
_terminated = true;
if (!ec)
_terminated = true;
}
void wait(std::error_code & ec) noexcept
@ -171,7 +173,8 @@ public:
{
int exit_code = 0;
boost::process::detail::api::wait(_child_handle, exit_code, ec);
_exit_status->store(exit_code);
if (!ec)
_exit_status->store(exit_code);
}
}
@ -188,7 +191,7 @@ public:
{
int exit_code = 0;
auto b = boost::process::detail::api::wait_until(_child_handle, exit_code, timeout_time, ec);
if (!b)
if (!b || ec)
return false;
_exit_status->store(exit_code);
}

View File

@ -125,7 +125,7 @@ inline bool wait_until(
~child_cleaner_t()
{
int res;
::kill(pid, -15);
::kill(pid, SIGTERM);
::waitpid(pid, &res, WNOHANG);
}
};

View File

@ -129,7 +129,7 @@ inline bool wait_until(
~child_cleaner_t()
{
int res;
::kill(pid, -15);
::kill(pid, SIGTERM);
::waitpid(pid, &res, WNOHANG);
}
};