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

Commit

Permalink
Closes #139
Browse files Browse the repository at this point in the history
  • Loading branch information
klemens-morgenstern committed Apr 10, 2019
1 parent af54484 commit e85f0d0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions include/boost/process/detail/child_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ class child

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;
Expand All @@ -159,10 +160,11 @@ class child

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
Expand All @@ -171,7 +173,8 @@ class child
{
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);
}
}

Expand All @@ -188,7 +191,7 @@ class child
{
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);
}
Expand Down

0 comments on commit e85f0d0

Please sign in to comment.