creation_flags.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // boost/process/v2/windows/default_launcher.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2022 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_PROCESS_V2_WINDOWS_CREATION_FLAGS_HPP
  11. #define BOOST_PROCESS_V2_WINDOWS_CREATION_FLAGS_HPP
  12. #include <boost/process/v2/windows/default_launcher.hpp>
  13. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  14. namespace windows
  15. {
  16. /// An initializers to add to the dwFlags in the startup-info
  17. /**
  18. * @tparam Flags The flags to be set.
  19. */
  20. template<DWORD Flags>
  21. struct process_creation_flags
  22. {
  23. constexpr process_creation_flags () {}
  24. error_code on_setup(windows::default_launcher & launcher,
  25. const filesystem::path &,
  26. const std::wstring &) const
  27. {
  28. launcher.creation_flags |= Flags;
  29. return error_code {};
  30. };
  31. };
  32. /// A flag to create a new process group. Necessary to allow interrupts for the subprocess.
  33. constexpr static process_creation_flags<CREATE_NEW_PROCESS_GROUP> create_new_process_group;
  34. constexpr static process_creation_flags<CREATE_BREAKAWAY_FROM_JOB> create_breakaway_from_job;
  35. constexpr static process_creation_flags<CREATE_NEW_CONSOLE> create_new_console;
  36. }
  37. BOOST_PROCESS_V2_END_NAMESPACE
  38. #endif // BOOST_PROCESS_V2_WINDOWS_CREATION_FLAGS_HPP