]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/process/detail/windows/is_running.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / process / detail / windows / is_running.hpp
1 // Copyright (c) 2106 Klemens D. Morgenstern
2 //
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)
5
6 #ifndef BOOST_PROCESS_WINDOWS_IS_RUNNING_HPP
7 #define BOOST_PROCESS_WINDOWS_IS_RUNNING_HPP
8
9 #include <boost/process/detail/config.hpp>
10 #include <system_error>
11 #include <cstdlib>
12 #include <boost/winapi/process.hpp>
13
14 namespace boost { namespace process { namespace detail { namespace windows {
15
16 constexpr static ::boost::winapi::DWORD_ still_active = 259;
17
18
19 struct child_handle;
20
21 inline bool is_running(const child_handle &p, int & exit_code)
22 {
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");
27
28 if (code == still_active)
29 return true;
30 else
31 {
32 exit_code = code;
33 return false;
34 }
35 }
36
37 inline bool is_running(const child_handle &p, int & exit_code, std::error_code &ec) noexcept
38 {
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();
43 else
44 ec.clear();
45
46 if (code == still_active)
47 return true;
48 else
49 {
50 exit_code = code;
51 return false;
52 }
53 }
54
55 inline bool is_running(int code)
56 {
57 return code == still_active;
58 }
59
60 inline int eval_exit_status(int in ) {return in;}
61
62 }}}}
63
64 #endif