exe.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2022 Klemens D. Morgenstern
  2. // Copyright (c) 2022 Samuel Venable
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_PROCESS_V2_EXE_HPP
  7. #define BOOST_PROCESS_V2_EXE_HPP
  8. #include <boost/process/v2/detail/config.hpp>
  9. #include <boost/process/v2/detail/throw_error.hpp>
  10. #include <boost/process/v2/process_handle.hpp>
  11. #include <boost/process/v2/pid.hpp>
  12. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  13. namespace ext {
  14. #if defined(BOOST_PROCESS_V2_WINDOWS)
  15. BOOST_PROCESS_V2_DECL filesystem::path exe(HANDLE handle, error_code & ec);
  16. BOOST_PROCESS_V2_DECL filesystem::path exe(HANDLE handle);
  17. #endif
  18. /// @{
  19. /// Return the executable of another process by pid or handle.
  20. BOOST_PROCESS_V2_DECL filesystem::path exe(pid_type pid, error_code & ec);
  21. BOOST_PROCESS_V2_DECL filesystem::path exe(pid_type pid);
  22. template<typename Executor>
  23. filesystem::path exe(basic_process_handle<Executor> & handle, error_code & ec)
  24. {
  25. #if defined(BOOST_PROCESS_V2_WINDOWS)
  26. return exe(handle.native_handle(), ec);
  27. #else
  28. return exe(handle.id(), ec);
  29. #endif
  30. }
  31. template<typename Executor>
  32. filesystem::path exe(basic_process_handle<Executor> & handle)
  33. {
  34. #if defined(BOOST_PROCESS_V2_WINDOWS)
  35. return exe(handle.native_handle());
  36. #else
  37. return exe(handle.id());
  38. #endif
  39. }
  40. ///@}
  41. } // namespace ext
  42. BOOST_PROCESS_V2_END_NAMESPACE
  43. #endif // BOOST_PROCESS_V2_EXE_HPP