exe.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /// @{
  15. /// Return the executable of another process by pid or handle.
  16. BOOST_PROCESS_V2_DECL filesystem::path exe(pid_type pid, error_code & ec);
  17. BOOST_PROCESS_V2_DECL filesystem::path exe(pid_type pid);
  18. template<typename Executor>
  19. filesystem::path exe(basic_process_handle<Executor> & handle, error_code & ec)
  20. {
  21. #if defined(BOOST_PROCESS_V2_WINDOWS)
  22. return exe(handle.native_handle(), ec);
  23. #else
  24. return exe(handle.id(), ec);
  25. #endif
  26. }
  27. template<typename Executor>
  28. filesystem::path exe(basic_process_handle<Executor> & handle)
  29. {
  30. #if defined(BOOST_PROCESS_V2_WINDOWS)
  31. return exe(handle.native_handle());
  32. #else
  33. return exe(handle.id());
  34. #endif
  35. }
  36. ///@}
  37. #if defined(BOOST_PROCESS_V2_WINDOWS)
  38. BOOST_PROCESS_V2_DECL filesystem::path exe(HANDLE handle, error_code & ec);
  39. BOOST_PROCESS_V2_DECL filesystem::path exe(HANDLE handle);
  40. #endif
  41. } // namespace ext
  42. BOOST_PROCESS_V2_END_NAMESPACE
  43. #if defined(BOOST_PROCESS_V2_HEADER_ONLY)
  44. #include <boost/process/v2/ext/impl/exe.ipp>
  45. #endif
  46. #endif // BOOST_PROCESS_V2_EXE_HPP