mirror of
https://github.com/boostorg/process.git
synced 2026-01-19 04:22:15 +00:00
unified cancellation on process.async_wait()
This commit is contained in:
@@ -299,6 +299,7 @@ struct basic_process_handle_fd
|
||||
template<typename Self>
|
||||
void operator()(Self &&self)
|
||||
{
|
||||
self.reset_cancellation_state(asio::enable_total_cancellation());
|
||||
error_code ec;
|
||||
native_exit_code_type exit_code{};
|
||||
int wait_res = -1;
|
||||
|
||||
@@ -329,8 +329,15 @@ struct basic_process_handle_fd_or_signal
|
||||
pid_type pid_;
|
||||
bool needs_post = true;
|
||||
|
||||
template<typename Self.
|
||||
void operator()(Self && self)
|
||||
{
|
||||
self.reset_cancellation_state(asio::enable_total_cancellation());
|
||||
(*this)(std::move(self), error_code{});
|
||||
}
|
||||
|
||||
template<typename Self>
|
||||
void operator()(Self &&self, error_code ec = {}, int = 0)
|
||||
void operator()(Self &&self, error_code ec, int = 0)
|
||||
{
|
||||
native_exit_code_type exit_code{};
|
||||
int wait_res = -1;
|
||||
|
||||
@@ -292,6 +292,7 @@ struct basic_process_handle_signal
|
||||
template<typename Self>
|
||||
void operator()(Self &&self)
|
||||
{
|
||||
self.reset_cancellation_state(asio::enable_total_cancellation());
|
||||
handle.async_wait(std::move(self));
|
||||
handle.cancel();
|
||||
// we cancel so we end up on the signal-sets executor
|
||||
|
||||
@@ -288,6 +288,17 @@ struct basic_process_handle_win
|
||||
template<typename Self>
|
||||
void operator()(Self &&self)
|
||||
{
|
||||
|
||||
self.reset_cancellation_state(asio::enable_total_cancellation());
|
||||
auto sl = self.get_cancellation_state().slot();
|
||||
auto & h = handle;
|
||||
if (sl.is_connected())
|
||||
sl.assign(
|
||||
[&h](asio::cancellation_type ct)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
h.cancel(ec);
|
||||
});
|
||||
handle.async_wait(std::move(self));
|
||||
}
|
||||
|
||||
@@ -295,6 +306,9 @@ struct basic_process_handle_win
|
||||
void operator()(Self &&self, error_code ec)
|
||||
{
|
||||
native_exit_code_type exit_code{};
|
||||
if (ec == asio::error::operation_aborted && !self.get_cancellation_state().cancelled())
|
||||
return handle.async_wait(std::move(self));
|
||||
|
||||
if (!ec)
|
||||
detail::get_exit_code_(handle.native_handle(), exit_code, ec);
|
||||
std::move(self).complete(ec, exit_code);
|
||||
|
||||
Reference in New Issue
Block a user