mirror of
https://github.com/boostorg/process.git
synced 2026-01-19 16:32:15 +00:00
Compare commits
15 Commits
issue/285b
...
boost-1.85
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
406cd3ecf3 | ||
|
|
c6951ff773 | ||
|
|
f2330c195a | ||
|
|
2ae279bd15 | ||
|
|
7a17af0f5c | ||
|
|
768944672f | ||
|
|
46acb247f5 | ||
|
|
08e3549713 | ||
|
|
029ad735fe | ||
|
|
03a348ebdd | ||
|
|
f289f26c87 | ||
|
|
8d9aa1e31d | ||
|
|
1873f34435 | ||
|
|
5f795d9e62 | ||
|
|
f17be678f2 |
@@ -33,7 +33,7 @@ inline std::vector<native_handle_type> get_handles(std::error_code & ec)
|
||||
else
|
||||
ec.clear();
|
||||
|
||||
auto my_fd = ::dirfd(dir.get());
|
||||
auto my_fd = dirfd(dir.get());
|
||||
|
||||
struct ::dirent * ent_p;
|
||||
|
||||
@@ -117,7 +117,7 @@ struct limit_handles_ : handler_base_ext
|
||||
return;
|
||||
}
|
||||
|
||||
auto my_fd = ::dirfd(dir);
|
||||
auto my_fd = dirfd(dir);
|
||||
struct ::dirent * ent_p;
|
||||
|
||||
while ((ent_p = readdir(dir)) != nullptr)
|
||||
|
||||
@@ -14,15 +14,25 @@
|
||||
#include <boost/process/pipe.hpp>
|
||||
#include <boost/process/detail/posix/handler.hpp>
|
||||
#include <unistd.h>
|
||||
#include <array>
|
||||
#include <boost/process/detail/used_handles.hpp>
|
||||
|
||||
namespace boost { namespace process { namespace detail { namespace posix {
|
||||
|
||||
template<int p1, int p2>
|
||||
struct pipe_out : handler_base_ext
|
||||
struct pipe_out : handler_base_ext, ::boost::process::detail::uses_handles
|
||||
{
|
||||
int sink;
|
||||
int source; //opposite end
|
||||
|
||||
std::array<int, 4> get_used_handles()
|
||||
{
|
||||
const auto pp1 = p1 != -1 ? p1 : p2;
|
||||
const auto pp2 = p2 != -1 ? p2 : p1;
|
||||
|
||||
return {source, sink, pp1, pp2};
|
||||
}
|
||||
|
||||
pipe_out(int sink, int source) : sink(sink), source(source) {}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -65,7 +65,7 @@ inline auto native_environment_impl<Char>::get(const pointer_type id) -> string_
|
||||
{
|
||||
auto err = ::boost::winapi::GetLastError();
|
||||
if (err == ::boost::winapi::ERROR_ENVVAR_NOT_FOUND_)//well, then we consider that an empty value
|
||||
return "";
|
||||
return string_type();
|
||||
else
|
||||
throw process_error(std::error_code(err, std::system_category()),
|
||||
"GetEnvironmentVariable() failed");
|
||||
|
||||
@@ -84,22 +84,32 @@ struct basic_process_handle_win
|
||||
|
||||
|
||||
template<typename Executor1>
|
||||
basic_process_handle_win(basic_process_handle_win<Executor1> && handle)
|
||||
: pid_(handle.pid_), handle_(std::move(handle.handle_))
|
||||
basic_process_handle_win(basic_process_handle_win<Executor1> && other)
|
||||
: pid_(other.pid_), handle_(std::move(other.handle_))
|
||||
{
|
||||
other.pid_ = static_cast<DWORD>(-1);
|
||||
}
|
||||
|
||||
basic_process_handle_win(basic_process_handle_win && handle)
|
||||
: pid_(handle.id()), handle_(std::move(handle.handle_))
|
||||
basic_process_handle_win(basic_process_handle_win && other)
|
||||
: pid_(other.pid_), handle_(std::move(other.handle_))
|
||||
{
|
||||
handle.pid_ = static_cast<DWORD>(-1);
|
||||
other.pid_ = static_cast<DWORD>(-1);
|
||||
}
|
||||
|
||||
basic_process_handle_win& operator=(basic_process_handle_win && handle)
|
||||
basic_process_handle_win& operator=(basic_process_handle_win && other)
|
||||
{
|
||||
pid_ = handle.pid_;
|
||||
handle_ = std::move(handle.handle_);
|
||||
handle.pid_ = static_cast<DWORD>(-1);
|
||||
pid_ = other.pid_;
|
||||
handle_ = std::move(other.handle_);
|
||||
other.pid_ = static_cast<DWORD>(-1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Executor1>
|
||||
basic_process_handle_win& operator=(basic_process_handle_win<Executor1> && other)
|
||||
{
|
||||
pid_ = other.pid_;
|
||||
handle_ = std::move(other.handle_);
|
||||
other.pid_ = static_cast<DWORD>(-1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
#include <boost/process/v2/detail/config.hpp>
|
||||
#include <boost/process/v2/cstring_ref.hpp>
|
||||
#include <boost/process/v2/detail/utf8.hpp>
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
#if !defined(GENERATING_DOCUMENTATION)
|
||||
#if defined(BOOST_PROCESS_V2_WINDOWS)
|
||||
|
||||
@@ -110,7 +110,7 @@ async_execute(basic_process<Executor> proc,
|
||||
WaitHandler && handler BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor))
|
||||
{
|
||||
std::unique_ptr<basic_process<Executor>> pro_(new basic_process<Executor>(std::move(proc)));
|
||||
auto exec = proc.get_executor();
|
||||
auto exec = pro_->get_executor();
|
||||
return BOOST_PROCESS_V2_ASIO_NAMESPACE::async_compose<WaitHandler, void(error_code, int)>(
|
||||
detail::execute_op<Executor>{std::move(pro_)}, handler, exec);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,11 @@ typedef int native_exit_code_type;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
constexpr native_exit_code_type still_active = 0x7f;
|
||||
constexpr native_exit_code_type still_active = 0x17f;
|
||||
static_assert(WIFSTOPPED(still_active), "Expected still_active to indicate WIFSTOPPED");
|
||||
static_assert(!WIFEXITED(still_active), "Expected still_active to not indicate WIFEXITED");
|
||||
static_assert(!WIFSIGNALED(still_active), "Expected still_active to not indicate WIFSIGNALED");
|
||||
static_assert(!WIFCONTINUED(still_active), "Expected still_active to not indicate WIFCONTINUED");
|
||||
}
|
||||
|
||||
inline bool process_is_running(int code)
|
||||
|
||||
@@ -112,13 +112,19 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code
|
||||
|
||||
filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code & ec)
|
||||
{
|
||||
#if (defined(__linux__) || defined(__ANDROID__))
|
||||
return filesystem::canonical(
|
||||
filesystem::path("/proc") / std::to_string(pid) / "cwd", ec);
|
||||
filesystem::path("/proc") / std::to_string(pid) / "cwd", ec
|
||||
);
|
||||
#elif defined(__sun)
|
||||
return fileystem::canonical(
|
||||
filesystem::path("/proc") / std::to_string(pid) / "path/cwd", ec
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
// FIXME: Add error handling.
|
||||
filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code & ec)
|
||||
{
|
||||
filesystem::path path;
|
||||
@@ -132,9 +138,7 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code
|
||||
filestat *fst = nullptr;
|
||||
STAILQ_FOREACH(fst, head, next) {
|
||||
if (fst->fs_uflags & PS_FST_UFLAG_CDIR)
|
||||
{
|
||||
path = filesystem::canonical(fst->fs_path, ec);
|
||||
}
|
||||
}
|
||||
procstat_freefiles(proc_stat, head);
|
||||
}
|
||||
@@ -153,7 +157,6 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code
|
||||
|
||||
#elif defined(__DragonFly__)
|
||||
|
||||
// FIXME: Add error handling.
|
||||
filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code & ec)
|
||||
{
|
||||
filesystem::path path;
|
||||
@@ -178,7 +181,8 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code
|
||||
}
|
||||
else
|
||||
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
|
||||
pclose(fp);
|
||||
if (pclose(fp) == -1)
|
||||
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
|
||||
}
|
||||
else
|
||||
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
|
||||
|
||||
@@ -133,7 +133,7 @@ filesystem::path exe(boost::process::v2::pid_type pid, boost::system::error_code
|
||||
);
|
||||
#elif defined(__sun)
|
||||
return fileystem::canonical(
|
||||
filesystem::path("/proc") / std::to_string(pid) / "path/a.out"
|
||||
filesystem::path("/proc") / std::to_string(pid) / "path/a.out", ec
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <boost/process/v2/detail/config.hpp>
|
||||
#include <boost/process/v2/detail/throw_error.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
BOOST_PROCESS_V2_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
@@ -101,7 +101,7 @@ void close_all(const std::vector<int> & whitelist, error_code & ec)
|
||||
idx++)
|
||||
{
|
||||
const auto mine = whitelist[idx];
|
||||
const auto next = whitelist[idx];
|
||||
const auto next = whitelist[idx + 1];
|
||||
if ((mine + 1) != next && (mine != next))
|
||||
{
|
||||
::close_range(mine + 1, next - 1, 0);
|
||||
@@ -132,7 +132,7 @@ void close_all(const std::vector<int> & whitelist, error_code & ec)
|
||||
idx++)
|
||||
{
|
||||
const auto mine = whitelist[idx];
|
||||
const auto next = whitelist[idx];
|
||||
const auto next = whitelist[idx + 1];
|
||||
if ((mine + 1) != next && (mine != next))
|
||||
{
|
||||
::close_range(mine + 1, next - 1, CLOSE_RANGE_UNSHARE);
|
||||
|
||||
@@ -21,7 +21,7 @@ process_standalone_test(pipe)
|
||||
|
||||
function(process_sub_launch_test name )
|
||||
add_executable(boost_process_${name} ${name}.cpp)
|
||||
target_link_libraries(boost_process_${name} Boost::process Boost::system Boost::filesystem Boost::thread Boost::unit_test_framework)
|
||||
target_link_libraries(boost_process_${name} Boost::process Boost::system Boost::filesystem Boost::scope_exit Boost::thread Boost::unit_test_framework)
|
||||
add_test(NAME boost_process_${name} COMMAND $<TARGET_FILE:boost_process_${name}> $<TARGET_FILE:boost_process_sub_launch> )
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
#include <boost/process/filesystem.hpp>
|
||||
|
||||
#if !defined(BOOST_PROCESS_USE_STD_FS)
|
||||
#include <boost/filesystem/directory.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#include <system_error>
|
||||
|
||||
|
||||
|
||||
@@ -625,7 +625,7 @@ BOOST_AUTO_TEST_CASE(async_request_exit)
|
||||
#endif
|
||||
);
|
||||
|
||||
asio::steady_timer tim{ctx, std::chrono::milliseconds(50)};
|
||||
asio::steady_timer tim{ctx, std::chrono::milliseconds(250)};
|
||||
asio::cancellation_signal sig;
|
||||
|
||||
bpv::async_execute(std::move(proc),
|
||||
|
||||
Reference in New Issue
Block a user