cmd.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_CMD_HPP
  7. #define BOOST_PROCESS_V2_CMD_HPP
  8. #include <string>
  9. #include <vector>
  10. #include <memory>
  11. #include <boost/process/v2/detail/config.hpp>
  12. #include <boost/process/v2/detail/throw_error.hpp>
  13. #include <boost/process/v2/process_handle.hpp>
  14. #include <boost/process/v2/pid.hpp>
  15. #include <boost/process/v2/shell.hpp>
  16. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  17. namespace ext {
  18. #if defined(BOOST_PROCESS_V2_WINDOWS)
  19. BOOST_PROCESS_V2_DECL shell cmd(HANDLE handle, error_code & ec);
  20. BOOST_PROCESS_V2_DECL shell cmd(HANDLE handle);
  21. #endif
  22. /// @{
  23. /// Get the argument vector of another process
  24. BOOST_PROCESS_V2_DECL shell cmd(pid_type pid, error_code & ec);
  25. BOOST_PROCESS_V2_DECL shell cmd(pid_type pid);
  26. #if defined(BOOST_PROCESS_V2_WINDOWS)
  27. BOOST_PROCESS_V2_DECL shell cmd(HANDLE handle, error_code & ec);
  28. BOOST_PROCESS_V2_DECL shell cmd(HANDLE handle);
  29. #endif
  30. template<typename Executor>
  31. inline shell cmd(basic_process_handle<Executor> & handle, error_code & ec)
  32. {
  33. #if defined(BOOST_PROCESS_V2_WINDOWS)
  34. return cmd(handle.native_handle(), ec);
  35. #else
  36. return cmd(handle.id(), ec);
  37. #endif
  38. }
  39. template<typename Executor>
  40. inline shell cmd(basic_process_handle<Executor> & handle)
  41. {
  42. #if defined(BOOST_PROCESS_V2_WINDOWS)
  43. return cmd(handle.native_handle());
  44. #else
  45. return cmd(handle.id());
  46. #endif
  47. }
  48. /// @}
  49. } // namespace ext
  50. BOOST_PROCESS_V2_END_NAMESPACE
  51. #endif // BOOST_PROCESS_V2_CMD_HPP