1 // Copyright (c) 2106 Klemens D. Morgenstern
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_PROCESS_WINDOWS_IS_RUNNING_HPP
7 #define BOOST_PROCESS_WINDOWS_IS_RUNNING_HPP
9 #include <boost/process/detail/config.hpp>
10 #include <system_error>
12 #include <boost/winapi/process.hpp>
14 namespace boost { namespace process { namespace detail { namespace windows {
16 constexpr static ::boost::winapi::DWORD_ still_active = 259;
21 inline bool is_running(const child_handle &p, int & exit_code)
23 ::boost::winapi::DWORD_ code;
24 //single value, not needed in the winapi.
25 if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &code))
26 ::boost::process::detail::throw_last_error("GetExitCodeProcess() failed");
28 if (code == still_active)
37 inline bool is_running(const child_handle &p, int & exit_code, std::error_code &ec) noexcept
39 ::boost::winapi::DWORD_ code;
40 //single value, not needed in the winapi.
41 if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &code))
42 ec = ::boost::process::detail::get_last_error();
46 if (code == still_active)
55 inline bool is_running(int code)
57 return code == still_active;
60 inline int eval_exit_status(int in ) {return in;}