summaryrefslogtreecommitdiff
path: root/boost/process/detail/windows
diff options
context:
space:
mode:
Diffstat (limited to 'boost/process/detail/windows')
-rw-r--r--boost/process/detail/windows/async_pipe.hpp22
-rw-r--r--boost/process/detail/windows/file_descriptor.hpp12
-rw-r--r--boost/process/detail/windows/group_handle.hpp2
-rw-r--r--boost/process/detail/windows/is_running.hpp26
-rw-r--r--boost/process/detail/windows/job_workaround.hpp12
-rw-r--r--boost/process/detail/windows/locale.hpp20
-rw-r--r--boost/process/detail/windows/show_window.hpp10
-rw-r--r--boost/process/detail/windows/terminate.hpp17
-rw-r--r--boost/process/detail/windows/wait_for_exit.hpp140
-rw-r--r--boost/process/detail/windows/wait_group.hpp94
10 files changed, 138 insertions, 217 deletions
diff --git a/boost/process/detail/windows/async_pipe.hpp b/boost/process/detail/windows/async_pipe.hpp
index 6cae1a584f..1bc2c8fec5 100644
--- a/boost/process/detail/windows/async_pipe.hpp
+++ b/boost/process/detail/windows/async_pipe.hpp
@@ -27,7 +27,7 @@ inline std::string make_pipe_name()
auto pid = ::boost::winapi::GetCurrentProcessId();
- static std::atomic_size_t cnt = 0;
+ static std::atomic_size_t cnt{0};
name += std::to_string(pid);
name += "_";
name += std::to_string(cnt++);
@@ -144,6 +144,18 @@ public:
return _sink.write_some(buffers);
}
+
+ template<typename MutableBufferSequence>
+ std::size_t read_some(const MutableBufferSequence & buffers, boost::system::error_code & ec) noexcept
+ {
+ return _source.read_some(buffers, ec);
+ }
+ template<typename MutableBufferSequence>
+ std::size_t write_some(const MutableBufferSequence & buffers, boost::system::error_code & ec) noexcept
+ {
+ return _sink.write_some(buffers, ec);
+ }
+
native_handle_type native_source() const {return const_cast<boost::asio::windows::stream_handle&>(_source).native_handle();}
native_handle_type native_sink () const {return const_cast<boost::asio::windows::stream_handle&>(_sink ).native_handle();}
@@ -265,7 +277,11 @@ async_pipe::async_pipe(boost::asio::io_context & ios_source,
static constexpr int FILE_FLAG_OVERLAPPED_ = 0x40000000; //temporary
::boost::winapi::HANDLE_ source = ::boost::winapi::create_named_pipe(
+#if defined(BOOST_NO_ANSI_APIS)
+ ::boost::process::detail::convert(name).c_str(),
+#else
name.c_str(),
+#endif
::boost::winapi::PIPE_ACCESS_INBOUND_
| FILE_FLAG_OVERLAPPED_, //write flag
0, 1, 8192, 8192, 0, nullptr);
@@ -277,7 +293,11 @@ async_pipe::async_pipe(boost::asio::io_context & ios_source,
_source.assign(source);
::boost::winapi::HANDLE_ sink = boost::winapi::create_file(
+#if defined(BOOST_NO_ANSI_APIS)
+ ::boost::process::detail::convert(name).c_str(),
+#else
name.c_str(),
+#endif
::boost::winapi::GENERIC_WRITE_, 0, nullptr,
::boost::winapi::OPEN_EXISTING_,
FILE_FLAG_OVERLAPPED_, //to allow read
diff --git a/boost/process/detail/windows/file_descriptor.hpp b/boost/process/detail/windows/file_descriptor.hpp
index 80e4c8ae8f..5058080cc4 100644
--- a/boost/process/detail/windows/file_descriptor.hpp
+++ b/boost/process/detail/windows/file_descriptor.hpp
@@ -45,11 +45,19 @@ struct file_descriptor
}
file_descriptor(const std::string & path , mode_t mode = read_write)
- : file_descriptor(path.c_str(), mode) {}
+#if defined(BOOST_NO_ANSI_APIS)
+ : file_descriptor(::boost::process::detail::convert(path), mode)
+#else
+ : file_descriptor(path.c_str(), mode)
+#endif
+ {}
file_descriptor(const std::wstring & path, mode_t mode = read_write)
: file_descriptor(path.c_str(), mode) {}
file_descriptor(const char* path, mode_t mode = read_write)
+#if defined(BOOST_NO_ANSI_APIS)
+ : file_descriptor(std::string(path), mode)
+#else
: _handle(
::boost::winapi::create_file(
path,
@@ -62,8 +70,8 @@ struct file_descriptor
::boost::winapi::FILE_ATTRIBUTE_NORMAL_,
nullptr
))
+#endif
{
-
}
file_descriptor(const wchar_t * path, mode_t mode = read_write)
: _handle(
diff --git a/boost/process/detail/windows/group_handle.hpp b/boost/process/detail/windows/group_handle.hpp
index 5025c0d245..42b0a9280d 100644
--- a/boost/process/detail/windows/group_handle.hpp
+++ b/boost/process/detail/windows/group_handle.hpp
@@ -103,7 +103,7 @@ struct group_handle
}
- group_handle() : group_handle(::boost::winapi::CreateJobObjectA(nullptr, nullptr))
+ group_handle() : group_handle(::boost::winapi::CreateJobObjectW(nullptr, nullptr))
{
}
diff --git a/boost/process/detail/windows/is_running.hpp b/boost/process/detail/windows/is_running.hpp
index 920693d116..d8e5a6fb7c 100644
--- a/boost/process/detail/windows/is_running.hpp
+++ b/boost/process/detail/windows/is_running.hpp
@@ -18,22 +18,6 @@ constexpr static ::boost::winapi::DWORD_ still_active = 259;
struct child_handle;
-inline bool is_running(const child_handle &p, int & exit_code)
-{
- ::boost::winapi::DWORD_ code;
- //single value, not needed in the winapi.
- if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &code))
- ::boost::process::detail::throw_last_error("GetExitCodeProcess() failed");
-
- if (code == still_active)
- return true;
- else
- {
- exit_code = code;
- return false;
- }
-}
-
inline bool is_running(const child_handle &p, int & exit_code, std::error_code &ec) noexcept
{
::boost::winapi::DWORD_ code;
@@ -49,7 +33,15 @@ inline bool is_running(const child_handle &p, int & exit_code, std::error_code &
{
exit_code = code;
return false;
- }
+ }
+}
+
+inline bool is_running(const child_handle &p, int & exit_code)
+{
+ std::error_code ec;
+ bool b = is_running(p, exit_code, ec);
+ boost::process::detail::throw_error(ec, "GetExitCodeProcess() failed in is_running");
+ return b;
}
inline bool is_running(int code)
diff --git a/boost/process/detail/windows/job_workaround.hpp b/boost/process/detail/windows/job_workaround.hpp
index 16534ce003..574e406609 100644
--- a/boost/process/detail/windows/job_workaround.hpp
+++ b/boost/process/detail/windows/job_workaround.hpp
@@ -82,7 +82,7 @@ typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION_ {
_Out_opt_ LPDWORD lpReturnLength
);
*/
-typedef ::boost::winapi::BOOL_ ( WINAPI *query_information_job_object_p)(
+typedef ::boost::winapi::BOOL_ (*query_information_job_object_p)(
::boost::winapi::HANDLE_,
JOBOBJECTINFOCLASS_,
void *,
@@ -90,14 +90,14 @@ typedef ::boost::winapi::BOOL_ ( WINAPI *query_information_job_object_p)(
::boost::winapi::DWORD_ *);
-inline ::boost::winapi::BOOL_ WINAPI query_information_job_object(
+inline ::boost::winapi::BOOL_ query_information_job_object(
::boost::winapi::HANDLE_ hJob,
JOBOBJECTINFOCLASS_ JobObjectInfoClass,
void * lpJobObjectInfo,
::boost::winapi::DWORD_ cbJobObjectInfoLength,
::boost::winapi::DWORD_ *lpReturnLength)
{
- static ::boost::winapi::HMODULE_ h = ::boost::winapi::get_module_handle("Kernel32.dll");
+ static ::boost::winapi::HMODULE_ h = ::boost::winapi::get_module_handle(L"Kernel32.dll");
static query_information_job_object_p f = reinterpret_cast<query_information_job_object_p>(::boost::winapi::get_proc_address(h, "QueryInformationJobObject"));
return (*f)(hJob, JobObjectInfoClass, lpJobObjectInfo, cbJobObjectInfoLength, lpReturnLength);
@@ -110,7 +110,7 @@ inline ::boost::winapi::BOOL_ WINAPI query_information_job_object(
_In_ DWORD cbJobObjectInfoLength
);*/
-typedef ::boost::winapi::BOOL_ ( WINAPI *set_information_job_object_p)(
+typedef ::boost::winapi::BOOL_ (*set_information_job_object_p)(
::boost::winapi::HANDLE_,
JOBOBJECTINFOCLASS_,
void *,
@@ -118,13 +118,13 @@ typedef ::boost::winapi::BOOL_ ( WINAPI *set_information_job_object_p)(
}
-inline ::boost::winapi::BOOL_ WINAPI set_information_job_object(
+inline ::boost::winapi::BOOL_ set_information_job_object(
::boost::winapi::HANDLE_ hJob,
JOBOBJECTINFOCLASS_ JobObjectInfoClass,
void * lpJobObjectInfo,
::boost::winapi::DWORD_ cbJobObjectInfoLength)
{
- static ::boost::winapi::HMODULE_ h = ::boost::winapi::get_module_handle("Kernel32.dll");
+ static ::boost::winapi::HMODULE_ h = ::boost::winapi::get_module_handle(L"Kernel32.dll");
static set_information_job_object_p f = reinterpret_cast<set_information_job_object_p>(::boost::winapi::get_proc_address(h, "SetInformationJobObject"));
return (*f)(hJob, JobObjectInfoClass, lpJobObjectInfo, cbJobObjectInfoLength);
diff --git a/boost/process/detail/windows/locale.hpp b/boost/process/detail/windows/locale.hpp
index 90b0110dc5..ee16c6347e 100644
--- a/boost/process/detail/windows/locale.hpp
+++ b/boost/process/detail/windows/locale.hpp
@@ -41,11 +41,15 @@ class windows_file_codecvt
wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const override
{
boost::ignore_unused(state);
- ::boost::winapi::UINT_ codepage = AreFileApisANSI() ?
- ::boost::winapi::CP_ACP_ :
- ::boost::winapi::CP_OEMCP_;
- int count;
+ auto codepage =
+#if !defined(BOOST_NO_ANSI_APIS)
+ ::boost::winapi::AreFileApisANSI() ?
+ ::boost::winapi::CP_ACP_ :
+#endif
+ ::boost::winapi::CP_OEMCP_;
+
+ int count = 0;
if ((count = ::boost::winapi::MultiByteToWideChar(codepage,
::boost::winapi::MB_PRECOMPOSED_, from,
static_cast<int>(from_end - from), to, static_cast<int>(to_end - to))) == 0)
@@ -64,11 +68,15 @@ class windows_file_codecvt
char* to, char* to_end, char*& to_next) const override
{
boost::ignore_unused(state);
- auto codepage = ::boost::winapi::AreFileApisANSI() ?
+ auto codepage =
+#if !defined(BOOST_NO_ANSI_APIS)
+ ::boost::winapi::AreFileApisANSI() ?
::boost::winapi::CP_ACP_ :
+#endif
::boost::winapi::CP_OEMCP_;
+ int count = 0;
+
- int count;
if ((count = ::boost::winapi::WideCharToMultiByte(codepage,
::boost::winapi::WC_NO_BEST_FIT_CHARS_, from,
static_cast<int>(from_end - from), to, static_cast<int>(to_end - to), 0, 0)) == 0)
diff --git a/boost/process/detail/windows/show_window.hpp b/boost/process/detail/windows/show_window.hpp
index 3cd2b44902..8821e0849c 100644
--- a/boost/process/detail/windows/show_window.hpp
+++ b/boost/process/detail/windows/show_window.hpp
@@ -29,8 +29,14 @@ struct show_window : ::boost::process::detail::handler_base
}
};
-
-
+struct create_no_window_ : public ::boost::process::detail::handler_base
+{
+ template <class Executor>
+ void on_setup(Executor &exec) const
+ {
+ exec.creation_flags |= ::boost::detail::winapi::CREATE_NO_WINDOW_;
+ }
+};
}}}}
diff --git a/boost/process/detail/windows/terminate.hpp b/boost/process/detail/windows/terminate.hpp
index ba66e4085c..8a413173da 100644
--- a/boost/process/detail/windows/terminate.hpp
+++ b/boost/process/detail/windows/terminate.hpp
@@ -20,15 +20,6 @@ namespace boost { namespace process { namespace detail { namespace windows {
struct child_handle;
-inline void terminate(child_handle &p)
-{
- if (!::boost::winapi::TerminateProcess(p.process_handle(), EXIT_FAILURE))
- boost::process::detail::throw_last_error("TerminateProcess() failed");
-
- ::boost::winapi::CloseHandle(p.proc_info.hProcess);
- p.proc_info.hProcess = ::boost::winapi::INVALID_HANDLE_VALUE_;
-}
-
inline void terminate(child_handle &p, std::error_code &ec) noexcept
{
if (!::boost::winapi::TerminateProcess(p.process_handle(), EXIT_FAILURE))
@@ -41,8 +32,12 @@ inline void terminate(child_handle &p, std::error_code &ec) noexcept
}
}
-
-
+inline void terminate(child_handle &p)
+{
+ std::error_code ec;
+ terminate(p, ec);
+ boost::process::detail::throw_error(ec, "TerminateProcess() failed in terminate");
+}
}}}}
diff --git a/boost/process/detail/windows/wait_for_exit.hpp b/boost/process/detail/windows/wait_for_exit.hpp
index 4219d9725a..37d24b1aeb 100644
--- a/boost/process/detail/windows/wait_for_exit.hpp
+++ b/boost/process/detail/windows/wait_for_exit.hpp
@@ -20,21 +20,6 @@
namespace boost { namespace process { namespace detail { namespace windows {
-inline void wait(child_handle &p, int & exit_code)
-{
- if (::boost::winapi::WaitForSingleObject(p.process_handle(),
- ::boost::winapi::infinite) == ::boost::winapi::wait_failed)
- throw_last_error("WaitForSingleObject() failed");
-
- ::boost::winapi::DWORD_ _exit_code;
- if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &_exit_code))
- throw_last_error("GetExitCodeProcess() failed");
-
- ::boost::winapi::CloseHandle(p.proc_info.hProcess);
- p.proc_info.hProcess = ::boost::winapi::INVALID_HANDLE_VALUE_;
- exit_code = static_cast<int>(_exit_code);
-}
-
inline void wait(child_handle &p, int & exit_code, std::error_code &ec) noexcept
{
::boost::winapi::DWORD_ _exit_code = 1;
@@ -56,64 +41,40 @@ inline void wait(child_handle &p, int & exit_code, std::error_code &ec) noexcept
exit_code = static_cast<int>(_exit_code);
}
-
-template< class Rep, class Period >
-inline bool wait_for(
- child_handle &p,
- int & exit_code,
- const std::chrono::duration<Rep, Period>& rel_time)
+inline void wait(child_handle &p, int & exit_code)
{
-
- std::chrono::milliseconds ms = std::chrono::duration_cast<std::chrono::milliseconds>(rel_time);
-
- ::boost::winapi::DWORD_ wait_code;
- wait_code = ::boost::winapi::WaitForSingleObject(p.process_handle(),
- static_cast<::boost::winapi::DWORD_>(ms.count()));
- if (wait_code == ::boost::winapi::wait_failed)
- throw_last_error("WaitForSingleObject() failed");
- else if (wait_code == ::boost::winapi::wait_timeout)
- return false; //
-
- ::boost::winapi::DWORD_ _exit_code;
- if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &_exit_code))
- throw_last_error("GetExitCodeProcess() failed");
-
- exit_code = static_cast<int>(_exit_code);
- ::boost::winapi::CloseHandle(p.proc_info.hProcess);
- p.proc_info.hProcess = ::boost::winapi::INVALID_HANDLE_VALUE_;
- return true;
+ std::error_code ec;
+ wait(p, exit_code, ec);
+ boost::process::detail::throw_error(ec, "wait error");
}
-
-template< class Rep, class Period >
-inline bool wait_for(
+template< class Clock, class Duration >
+inline bool wait_until(
child_handle &p,
int & exit_code,
- const std::chrono::duration<Rep, Period>& rel_time,
+ const std::chrono::time_point<Clock, Duration>& timeout_time,
std::error_code &ec) noexcept
{
-
- std::chrono::milliseconds ms = std::chrono::duration_cast<std::chrono::milliseconds>(rel_time);
-
+ std::chrono::milliseconds ms =
+ std::chrono::duration_cast<std::chrono::milliseconds>(
+ timeout_time - Clock::now());
::boost::winapi::DWORD_ wait_code;
wait_code = ::boost::winapi::WaitForSingleObject(p.process_handle(),
- static_cast<::boost::winapi::DWORD_>(ms.count()));
+ static_cast<::boost::winapi::DWORD_>(ms.count()));
+
if (wait_code == ::boost::winapi::wait_failed)
ec = std::error_code(
::boost::winapi::GetLastError(),
std::system_category());
else if (wait_code == ::boost::winapi::wait_timeout)
- return false; //
+ return false;
- ::boost::winapi::DWORD_ _exit_code = 1;
+ ::boost::winapi::DWORD_ _exit_code;
if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &_exit_code))
- {
ec = std::error_code(
::boost::winapi::GetLastError(),
std::system_category());
- return false;
- }
else
ec.clear();
@@ -121,7 +82,6 @@ inline bool wait_for(
::boost::winapi::CloseHandle(p.proc_info.hProcess);
p.proc_info.hProcess = ::boost::winapi::INVALID_HANDLE_VALUE_;
return true;
-;
}
template< class Clock, class Duration >
@@ -130,67 +90,33 @@ inline bool wait_until(
int & exit_code,
const std::chrono::time_point<Clock, Duration>& timeout_time)
{
- std::chrono::milliseconds ms =
- std::chrono::duration_cast<std::chrono::milliseconds>(
- timeout_time - std::chrono::system_clock::now());
-
- ::boost::winapi::DWORD_ wait_code;
- wait_code = ::boost::winapi::WaitForSingleObject(p.process_handle(),
- static_cast<::boost::winapi::DWORD_>(ms.count()));
-
- if (wait_code == ::boost::winapi::wait_failed)
- throw_last_error("WaitForSingleObject() failed");
- else if (wait_code == ::boost::winapi::wait_timeout)
- return false;
-
- ::boost::winapi::DWORD_ _exit_code;
- if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &_exit_code))
- throw_last_error("GetExitCodeProcess() failed");
-
- exit_code = static_cast<int>(_exit_code);
- ::boost::winapi::CloseHandle(p.proc_info.hProcess);
- p.proc_info.hProcess = ::boost::winapi::INVALID_HANDLE_VALUE_;
- return true;
+ std::error_code ec;
+ bool b = wait_until(p, exit_code, timeout_time, ec);
+ boost::process::detail::throw_error(ec, "wait_until error");
+ return b;
}
-
-template< class Clock, class Duration >
-inline bool wait_until(
+template< class Rep, class Period >
+inline bool wait_for(
child_handle &p,
int & exit_code,
- const std::chrono::time_point<Clock, Duration>& timeout_time,
+ const std::chrono::duration<Rep, Period>& rel_time,
std::error_code &ec) noexcept
{
- std::chrono::milliseconds ms =
- std::chrono::duration_cast<std::chrono::milliseconds>(
- timeout_time - std::chrono::system_clock::now());
-
- ::boost::winapi::DWORD_ wait_code;
- wait_code = ::boost::winapi::WaitForSingleObject(p.process_handle(),
- static_cast<::boost::winapi::DWORD_>(ms.count()));
-
- if (wait_code == ::boost::winapi::wait_failed)
- ec = std::error_code(
- ::boost::winapi::GetLastError(),
- std::system_category());
- else if (wait_code == ::boost::winapi::wait_timeout)
- return false;
-
- ::boost::winapi::DWORD_ _exit_code;
- if (!::boost::winapi::GetExitCodeProcess(p.process_handle(), &_exit_code))
- ec = std::error_code(
- ::boost::winapi::GetLastError(),
- std::system_category());
- else
- ec.clear();
-
- exit_code = static_cast<int>(_exit_code);
- ::boost::winapi::CloseHandle(p.proc_info.hProcess);
- p.proc_info.hProcess = ::boost::winapi::INVALID_HANDLE_VALUE_;
- return true;
-;
+ return wait_until(p, exit_code, std::chrono::steady_clock::now() + rel_time, ec);
}
+template< class Rep, class Period >
+inline bool wait_for(
+ child_handle &p,
+ int & exit_code,
+ const std::chrono::duration<Rep, Period>& rel_time)
+{
+ std::error_code ec;
+ bool b = wait_for(p, exit_code, rel_time, ec);
+ boost::process::detail::throw_error(ec, "wait_for error");
+ return b;
+}
}}}}
diff --git a/boost/process/detail/windows/wait_group.hpp b/boost/process/detail/windows/wait_group.hpp
index e0b18b1268..32a8cd8842 100644
--- a/boost/process/detail/windows/wait_group.hpp
+++ b/boost/process/detail/windows/wait_group.hpp
@@ -9,20 +9,12 @@
#include <boost/process/detail/config.hpp>
#include <boost/winapi/jobs.hpp>
#include <boost/winapi/wait.hpp>
-
+#include <chrono>
namespace boost { namespace process { namespace detail { namespace windows {
struct group_handle;
-inline void wait(const group_handle &p)
-{
- if (::boost::winapi::WaitForSingleObject(p.handle(),
- ::boost::winapi::infinite) == ::boost::winapi::wait_failed)
- throw_last_error("WaitForSingleObject() failed");
-
-}
-
inline void wait(const group_handle &p, std::error_code &ec)
{
if (::boost::winapi::WaitForSingleObject(p.handle(),
@@ -30,38 +22,26 @@ inline void wait(const group_handle &p, std::error_code &ec)
ec = get_last_error();
}
-
-template< class Rep, class Period >
-inline bool wait_for(
- const group_handle &p,
- const std::chrono::duration<Rep, Period>& rel_time)
+inline void wait(const group_handle &p)
{
-
- std::chrono::milliseconds ms = std::chrono::duration_cast<std::chrono::milliseconds>(rel_time);
-
- ::boost::winapi::DWORD_ wait_code;
- wait_code = ::boost::winapi::WaitForSingleObject(p.handle(), ms.count());
- if (wait_code == ::boost::winapi::wait_failed)
- throw_last_error("WaitForSingleObject() failed");
- else if (wait_code == ::boost::winapi::wait_timeout)
- return false; //
-
- return true;
+ std::error_code ec;
+ wait(p, ec);
+ boost::process::detail::throw_error(ec, "wait error");
}
-
-template< class Rep, class Period >
-inline bool wait_for(
+template< class Clock, class Duration >
+inline bool wait_until(
const group_handle &p,
- const std::chrono::duration<Rep, Period>& rel_time,
+ const std::chrono::time_point<Clock, Duration>& timeout_time,
std::error_code &ec)
{
-
- std::chrono::milliseconds ms = std::chrono::duration_cast<std::chrono::milliseconds>(rel_time);
-
+ std::chrono::milliseconds ms =
+ std::chrono::duration_cast<std::chrono::milliseconds>(
+ timeout_time - Clock::now());
::boost::winapi::DWORD_ wait_code;
wait_code = ::boost::winapi::WaitForSingleObject(p.handle(), ms.count());
+
if (wait_code == ::boost::winapi::wait_failed)
ec = get_last_error();
@@ -76,44 +56,30 @@ inline bool wait_until(
const group_handle &p,
const std::chrono::time_point<Clock, Duration>& timeout_time)
{
- std::chrono::milliseconds ms =
- std::chrono::duration_cast<std::chrono::milliseconds>(
- timeout_time - std::chrono::system_clock::now());
-
- ::boost::winapi::DWORD_ wait_code;
- wait_code = ::boost::winapi::WaitForSingleObject(p.handle(), ms.count());
-
- if (wait_code == ::boost::winapi::wait_failed)
- throw_last_error("WaitForSingleObject() failed");
-
- else if (wait_code == ::boost::winapi::wait_timeout)
- return false; //
-
- return true;
+ std::error_code ec;
+ bool b = wait_until(p, timeout_time, ec);
+ boost::process::detail::throw_error(ec, "wait_until error");
+ return b;
}
-
-template< class Clock, class Duration >
-inline bool wait_until(
+template< class Rep, class Period >
+inline bool wait_for(
const group_handle &p,
- const std::chrono::time_point<Clock, Duration>& timeout_time,
+ const std::chrono::duration<Rep, Period>& rel_time,
std::error_code &ec)
{
- std::chrono::milliseconds ms =
- std::chrono::duration_cast<std::chrono::milliseconds>(
- timeout_time - std::chrono::system_clock::now());
-
- ::boost::winapi::DWORD_ wait_code;
- wait_code = ::boost::winapi::WaitForSingleObject(p.handle(), ms.count());
-
- if (wait_code == ::boost::winapi::wait_failed)
- ec = get_last_error();
-
- else if (wait_code == ::boost::winapi::wait_timeout)
- return false; //
+ return wait_until(p, std::chrono::steady_clock::now() + rel_time, ec);
+}
- return true;
-;
+template< class Rep, class Period >
+inline bool wait_for(
+ const group_handle &p,
+ const std::chrono::duration<Rep, Period>& rel_time)
+{
+ std::error_code ec;
+ bool b = wait_for(p, rel_time, ec);
+ boost::process::detail::throw_error(ec, "wait_for error");
+ return b;
}
}}}}