File indexing completed on 2025-01-18 09:50:08
0001
0002
0003
0004
0005
0006 #ifndef BOOST_PROCESS_WINDOWS_ON_EXIT_HPP_
0007 #define BOOST_PROCESS_WINDOWS_ON_EXIT_HPP_
0008
0009 #include <boost/process/async.hpp>
0010 #include <boost/process/detail/config.hpp>
0011 #include <boost/process/detail/handler_base.hpp>
0012 #include <boost/process/detail/windows/async_handler.hpp>
0013 #include <boost/asio/execution.hpp>
0014 #include <system_error>
0015 #include <functional>
0016
0017 namespace boost { namespace process { namespace detail {
0018
0019 template<typename Tuple>
0020 inline asio::io_context& get_io_context(const Tuple & tup);
0021
0022 namespace windows {
0023
0024 struct on_exit_ : boost::process::detail::windows::async_handler
0025 {
0026 std::function<void(int, const std::error_code&)> handler;
0027 on_exit_(const std::function<void(int, const std::error_code&)> & handler) : handler(handler)
0028 {
0029
0030 }
0031
0032 template<typename Executor>
0033 std::function<void(int, const std::error_code&)> on_exit_handler(Executor& exec)
0034 {
0035 auto v = boost::asio::prefer(boost::process::detail::get_io_context(exec.seq).get_executor(),
0036 boost::asio::execution::outstanding_work.tracked);
0037 auto handler_ = this->handler;
0038 return [v, handler_](int exit_code, const std::error_code & ec)
0039 {
0040 handler_(static_cast<int>(exit_code), ec);
0041 };
0042
0043 }
0044 };
0045
0046
0047 }}}}
0048 #endif