1 // Copyright (c) 2016 Klemens D. Morgenstern
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_PROCESS_WINDOWS_ON_EXIT_HPP_
7 #define BOOST_PROCESS_WINDOWS_ON_EXIT_HPP_
9 #include <boost/process/detail/config.hpp>
10 #include <boost/process/detail/handler_base.hpp>
11 #include <boost/process/detail/windows/async_handler.hpp>
12 #include <system_error>
15 namespace boost { namespace process { namespace detail { namespace windows {
17 struct on_exit_ : boost::process::detail::windows::async_handler
19 std::function<void(int, const std::error_code&)> handler;
20 on_exit_(const std::function<void(int, const std::error_code&)> & handler) : handler(handler)
25 template<typename Executor>
26 std::function<void(int, const std::error_code&)> on_exit_handler(Executor&)
28 auto handler = this->handler;
29 return [handler](int exit_code, const std::error_code & ec)
31 handler(static_cast<int>(exit_code), ec);
39 #endif /* INCLUDE_BOOST_PROCESS_WINDOWS_ON_EXIT_HPP_ */