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_DETAIL_WINDOWS_GROUP_REF_HPP_
7 #define BOOST_PROCESS_DETAIL_WINDOWS_GROUP_REF_HPP_
9 #include <boost/process/detail/config.hpp>
10 #include <boost/process/detail/windows/group_handle.hpp>
11 #include <boost/winapi/process.hpp>
12 #include <boost/process/detail/windows/handler.hpp>
14 namespace boost { namespace process {
16 namespace detail { namespace windows {
20 struct group_ref : handler_base_ext
22 ::boost::winapi::HANDLE_ handle;
24 explicit group_ref(group_handle &g) :
28 template <class Executor>
29 void on_setup(Executor& exec) const
31 //I can only enable this if the current process supports breakaways.
32 if (in_group() && break_away_enabled(nullptr))
33 exec.creation_flags |= boost::winapi::CREATE_BREAKAWAY_FROM_JOB_;
37 template <class Executor>
38 void on_success(Executor& exec) const
40 if (!::boost::winapi::AssignProcessToJobObject(handle, exec.proc_info.hProcess))
41 exec.set_error(::boost::process::detail::get_last_error(),
42 "AssignProcessToJobObject() failed.");
51 #endif /* BOOST_PROCESS_DETAIL_WINDOWS_GROUP_HPP_ */