File indexing completed on 2025-01-18 09:50:08
0001
0002
0003
0004
0005
0006 #ifndef BOOST_PROCESS_WINDOWS_IS_RUNNING_HPP
0007 #define BOOST_PROCESS_WINDOWS_IS_RUNNING_HPP
0008
0009 #include <boost/process/detail/config.hpp>
0010 #include <boost/process/detail/windows/child_handle.hpp>
0011 #include <system_error>
0012 #include <cstdlib>
0013 #include <boost/winapi/process.hpp>
0014
0015 namespace boost { namespace process { namespace detail { namespace windows {
0016
0017 constexpr static ::boost::winapi::DWORD_ still_active = 259;
0018
0019
0020 struct child_handle;
0021
0022 inline bool is_running(const child_handle &p, int & exit_code, std::error_code &ec) noexcept
0023 {
0024 ::boost::winapi::DWORD_ code;
0025
0026 if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &code))
0027 ec = ::boost::process::detail::get_last_error();
0028 else
0029 ec.clear();
0030
0031 if (code == still_active)
0032 return true;
0033 else
0034 {
0035 exit_code = code;
0036 return false;
0037 }
0038 }
0039
0040 inline bool is_running(const child_handle &p, int & exit_code)
0041 {
0042 std::error_code ec;
0043 bool b = is_running(p, exit_code, ec);
0044 boost::process::detail::throw_error(ec, "GetExitCodeProcess() failed in is_running");
0045 return b;
0046 }
0047
0048 inline bool is_running(int code)
0049 {
0050 return code == still_active;
0051 }
0052
0053 inline int eval_exit_status(int in ) {return in;}
0054
0055 }}}}
0056
0057 #endif