mirror of
https://github.com/boostorg/process.git
synced 2026-01-20 16:52:14 +00:00
Compare commits
1 Commits
freebsd2
...
v2_handles
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6239f63c7 |
@@ -14,8 +14,8 @@ windowsglobalimage="cppalliance/dronevs2019"
|
||||
|
||||
def main(ctx):
|
||||
return [
|
||||
freebsd_cxx("gcc freebsd", "g++", buildtype="boost", buildscript="drone", freebsd_version="13.1", environment={'B2_TOOLSET': 'gcc', 'B2_CXXSTD': '11'}, globalenv=globalenv),
|
||||
freebsd_cxx("clang 14 freebsd", "clang++-14", buildtype="boost", buildscript="drone", freebsd_version="13.1", environment={'B2_TOOLSET': 'clang-14', 'B2_CXXSTD': '11'}, globalenv=globalenv),
|
||||
freebsd_cxx("gcc 11 freebsd", "g++-11", buildtype="boost", buildscript="drone", freebsd_version="13.1", environment={'B2_TOOLSET': 'gcc-11', 'B2_CXXSTD': '17,20', 'B2_LINKFLAGS': '-Wl,-rpath=/usr/local/lib/gcc11'}, globalenv=globalenv),
|
||||
freebsd_cxx("clang 14 freebsd", "clang++-14", buildtype="boost", buildscript="drone", freebsd_version="13.1", environment={'B2_TOOLSET': 'clang-14', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
|
||||
linux_cxx("docs", "", packages="docbook docbook-xml docbook-xsl xsltproc libsaxonhe-java default-jre-headless flex libfl-dev bison unzip rsync", image="cppalliance/droneubuntu1804:1", buildtype="docs", buildscript="drone", environment={"COMMENT": "docs"}, globalenv=globalenv),
|
||||
linux_cxx("asan", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'asan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '11', 'B2_ASAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'DRONE_EXTRA_PRIVILEGED': 'True', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv, privileged=True),
|
||||
linux_cxx("ubsan", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'ubsan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '11', 'B2_UBSAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'B2_LINKFLAGS': '-fuse-ld=gold', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
|
||||
|
||||
@@ -163,7 +163,7 @@ BOOST_PROCESS_V2_END_NAMESPACE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(BOOST_PROCESS_V2_DISABLE_PDFORK)
|
||||
#if defined(__FreeBSD__) && defined(BOOST_PROCESS_V2_ENABLE_PDFORK)
|
||||
#define BOOST_PROCESS_V2_PDFORK 1
|
||||
#define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
|
||||
#endif
|
||||
|
||||
@@ -315,13 +315,9 @@ struct basic_process_handle_fd_or_signal
|
||||
|
||||
struct async_wait_op_
|
||||
{
|
||||
net::posix::basic_stream_descriptor<Executor> &descriptor;
|
||||
net::posix::basic_descriptor<Executor> &descriptor;
|
||||
net::basic_signal_set<Executor> &handle;
|
||||
pid_type pid_;
|
||||
async_wait_op_(net::posix::basic_stream_descriptor<Executor> &descriptor,
|
||||
net::basic_signal_set<Executor> &handle,
|
||||
pid_type pid_) : descriptor(descriptor), handle(handle), pid_(pid_) {}
|
||||
|
||||
bool needs_post = true;
|
||||
|
||||
template<typename Self>
|
||||
@@ -347,11 +343,10 @@ struct basic_process_handle_fd_or_signal
|
||||
|
||||
if (!ec && (wait_res == 0))
|
||||
{
|
||||
static char dummy[128];
|
||||
needs_post = false;
|
||||
if (descriptor.is_open())
|
||||
descriptor.async_read_some(
|
||||
asio::buffer(dummy),
|
||||
descriptor.async_wait(
|
||||
net::posix::descriptor_base::wait_read,
|
||||
std::move(self));
|
||||
else
|
||||
handle.async_wait(std::move(self));
|
||||
@@ -384,10 +379,10 @@ struct basic_process_handle_fd_or_signal
|
||||
WaitHandler = net::default_completion_token_t<executor_type>>
|
||||
auto async_wait(WaitHandler &&handler = net::default_completion_token_t<executor_type>())
|
||||
-> decltype(net::async_compose<WaitHandler, void(error_code, native_exit_code_type)>(
|
||||
async_wait_op_(descriptor_, signal_set_, pid_), handler, descriptor_))
|
||||
async_wait_op_{descriptor_, signal_set_, pid_}, handler, descriptor_))
|
||||
{
|
||||
return net::async_compose<WaitHandler, void(error_code, native_exit_code_type)>(
|
||||
async_wait_op_(descriptor_, signal_set_, pid_), handler, descriptor_);
|
||||
async_wait_op_{descriptor_, signal_set_, pid_}, handler, descriptor_);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -303,12 +303,14 @@ struct process_stdio
|
||||
#if defined(BOOST_PROCESS_V2_WINDOWS)
|
||||
error_code on_setup(windows::default_launcher & launcher, const filesystem::path &, const std::wstring &)
|
||||
{
|
||||
|
||||
launcher.startup_info.StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
||||
launcher.startup_info.StartupInfo.hStdInput = in.prepare();
|
||||
launcher.startup_info.StartupInfo.hStdOutput = out.prepare();
|
||||
launcher.startup_info.StartupInfo.hStdError = err.prepare();
|
||||
launcher.inherit_handles = true;
|
||||
launcher.inherited_handles.reserve(launcher.inherited_handles.size() + 3);
|
||||
launcher.inherited_handles.push_back(launcher.startup_info.StartupInfo.hStdInput);
|
||||
launcher.inherited_handles.push_back(launcher.startup_info.StartupInfo.hStdOutput);
|
||||
launcher.inherited_handles.push_back(launcher.startup_info.StartupInfo.hStdError);
|
||||
return error_code {};
|
||||
};
|
||||
#else
|
||||
|
||||
@@ -91,13 +91,21 @@ struct as_user_launcher : default_launcher
|
||||
detail::on_error(*this, executable, command_line, ec, inits...);
|
||||
return basic_process<Executor>(exec);
|
||||
}
|
||||
|
||||
if (!inherited_handles.empty())
|
||||
{
|
||||
set_handle_list(ec);
|
||||
if (ec)
|
||||
return basic_process<Executor>(exec);
|
||||
}
|
||||
|
||||
auto ok = ::CreateProcessAsUserW(
|
||||
token,
|
||||
executable.empty() ? nullptr : executable.c_str(),
|
||||
command_line.empty() ? nullptr : &command_line.front(),
|
||||
process_attributes,
|
||||
thread_attributes,
|
||||
inherit_handles ? TRUE : FALSE,
|
||||
inherited_handles.empty() ? FALSE : TRUE,
|
||||
creation_flags,
|
||||
environment,
|
||||
current_directory.empty() ? nullptr : current_directory.c_str(),
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <boost/process/v2/error.hpp>
|
||||
|
||||
#include <numeric>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <windows.h>
|
||||
|
||||
#if defined(BOOST_PROCESS_V2_STANDALONE)
|
||||
@@ -207,8 +209,8 @@ struct default_launcher
|
||||
SECURITY_ATTRIBUTES * process_attributes = nullptr;
|
||||
//// The thread_attributes passed to CreateProcess
|
||||
SECURITY_ATTRIBUTES * thread_attributes = nullptr;
|
||||
/// The bInheritHandles option. Needs to be set to true by any initializers using handles.
|
||||
bool inherit_handles = false;
|
||||
/// The inhreited_handles option. bInheritHandles will be true if not empty..
|
||||
std::vector<HANDLE> inherited_handles;
|
||||
/// The creation flags of the process. Initializers may add to them; extended startupinfo is assumed.
|
||||
DWORD creation_flags{EXTENDED_STARTUPINFO_PRESENT};
|
||||
/// A pointer to the subprocess environment.
|
||||
@@ -294,18 +296,26 @@ struct default_launcher
|
||||
auto command_line = this->build_command_line(executable, std::forward<Args>(args));
|
||||
|
||||
ec = detail::on_setup(*this, executable, command_line, inits...);
|
||||
|
||||
if (ec)
|
||||
{
|
||||
detail::on_error(*this, executable, command_line, ec, inits...);
|
||||
return basic_process<Executor>(exec);
|
||||
}
|
||||
|
||||
if (!inherited_handles.empty())
|
||||
{
|
||||
set_handle_list(ec);
|
||||
if (ec)
|
||||
return basic_process<Executor>(exec);
|
||||
}
|
||||
|
||||
auto ok = ::CreateProcessW(
|
||||
executable.empty() ? nullptr : executable.c_str(),
|
||||
command_line.empty() ? nullptr : &command_line.front(),
|
||||
process_attributes,
|
||||
thread_attributes,
|
||||
inherit_handles ? TRUE : FALSE,
|
||||
inherited_handles.empty() ? FALSE : TRUE,
|
||||
creation_flags,
|
||||
environment,
|
||||
current_directory.empty() ? nullptr : current_directory.c_str(),
|
||||
@@ -403,6 +413,18 @@ struct default_launcher
|
||||
return args;
|
||||
}
|
||||
|
||||
struct lpproc_thread_closer
|
||||
{
|
||||
void operator()(::LPPROC_THREAD_ATTRIBUTE_LIST l)
|
||||
{
|
||||
::DeleteProcThreadAttributeList(l);
|
||||
::HeapFree(GetProcessHeap(), 0, l);
|
||||
}
|
||||
};
|
||||
std::unique_ptr<std::remove_pointer<LPPROC_THREAD_ATTRIBUTE_LIST>::type, lpproc_thread_closer> proc_attribute_list_storage;
|
||||
|
||||
BOOST_PROCESS_V2_DECL LPPROC_THREAD_ATTRIBUTE_LIST get_thread_attribute_list(error_code & ec);
|
||||
BOOST_PROCESS_V2_DECL void set_handle_list(error_code & ec);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,45 @@ namespace windows
|
||||
return itr - begin;
|
||||
}
|
||||
|
||||
LPPROC_THREAD_ATTRIBUTE_LIST default_launcher::get_thread_attribute_list(error_code & ec)
|
||||
{
|
||||
if (startup_info.lpAttributeList != nullptr)
|
||||
return startup_info.lpAttributeList;
|
||||
SIZE_T size;
|
||||
if (!(::InitializeProcThreadAttributeList(NULL, 1, 0, &size) ||
|
||||
GetLastError() == ERROR_INSUFFICIENT_BUFFER))
|
||||
{
|
||||
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(::HeapAlloc(::GetProcessHeap(), 0, size));
|
||||
if (lpAttributeList == nullptr)
|
||||
return nullptr;
|
||||
|
||||
if (!::InitializeProcThreadAttributeList(lpAttributeList, 1, 0, &size))
|
||||
{
|
||||
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec);
|
||||
::HeapFree(GetProcessHeap(), 0, lpAttributeList);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
proc_attribute_list_storage.reset(lpAttributeList);
|
||||
startup_info.lpAttributeList = proc_attribute_list_storage.get();
|
||||
return startup_info.lpAttributeList;
|
||||
}
|
||||
|
||||
void default_launcher::set_handle_list(error_code & ec)
|
||||
{
|
||||
auto tl = get_thread_attribute_list(ec);
|
||||
if (ec)
|
||||
return;
|
||||
if (!::UpdateProcThreadAttribute(
|
||||
tl, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST,
|
||||
inherited_handles.data(), inherited_handles.size() * sizeof(HANDLE), nullptr, nullptr))
|
||||
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec);
|
||||
}
|
||||
|
||||
}
|
||||
BOOST_PROCESS_V2_END_NAMESPACE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user