2
0
mirror of https://github.com/boostorg/process.git synced 2026-01-20 04:42:24 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Klemens Morgenstern
8e383bf726 environment::native_handle fix
closes #332
2023-08-08 08:38:00 +08:00
8 changed files with 15 additions and 29 deletions

View File

@@ -21,9 +21,7 @@
#include <system_error>
#include <boost/system/api_config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/process/exception.hpp>
#include <boost/assert/source_location.hpp>
#if defined(BOOST_POSIX_API)
#include <errno.h>
@@ -73,33 +71,31 @@ inline std::error_code get_last_error() noexcept
}
#endif
inline void throw_last_error(const std::string & msg, boost::source_location const & loc = boost::source_location())
inline void throw_last_error(const std::string & msg)
{
boost::throw_exception(process_error(get_last_error(), msg), loc);
throw process_error(get_last_error(), msg);
}
inline void throw_last_error(const char * msg, boost::source_location const & loc = boost::source_location())
inline void throw_last_error(const char * msg)
{
boost::throw_exception(process_error(get_last_error(), msg), loc);
throw process_error(get_last_error(), msg);
}
inline void throw_last_error(boost::source_location const & loc = boost::source_location())
inline void throw_last_error()
{
boost::throw_exception(process_error(get_last_error()), loc);
throw process_error(get_last_error());
}
inline void throw_error(const std::error_code& ec,
boost::source_location const & loc = boost::source_location())
inline void throw_error(const std::error_code& ec)
{
if (ec)
boost::throw_exception(process_error(ec), loc);
throw process_error(ec);
}
inline void throw_error(const std::error_code& ec, const char* msg,
boost::source_location const & loc = boost::source_location())
inline void throw_error(const std::error_code& ec, const char* msg)
{
if (ec)
boost::throw_exception(process_error(ec, msg), loc);
throw process_error(ec, msg);
}
template<typename Char> constexpr Char null_char();

View File

@@ -71,7 +71,7 @@ struct async_out_buffer : ::boost::process::detail::posix::handler_base_ext,
}
template <typename Executor>
inline void on_success(Executor &)
inline void on_success(Executor &exec)
{
auto pipe = this->pipe;
boost::asio::async_read(*pipe, buf,

View File

@@ -210,7 +210,7 @@ public:
Char ** _env_impl = &*_env_arr.data();
native_handle_type native_handle() const {return &_data.front();}
native_handle_type native_handle() const {return _env_impl;}
};

View File

@@ -445,7 +445,7 @@ child executor<Sequence>::invoke(boost::mpl::false_, boost::mpl::false_)
if (_ec)
{
//if an error occurred we need to reap the child process
::waitpid(this->pid, nullptr, 0);
::waitpid(this->pid, nullptr, WNOHANG);
boost::fusion::for_each(seq, call_on_error(*this, _ec));
return child();
}

View File

@@ -61,10 +61,6 @@ inline std::string build_args(const std::string & exe, std::vector<std::string>
arg += '"';
}
}
else
{
arg = "\"\"";
}
if (!st.empty())//first one does not need a preceding space
st += ' ';
@@ -109,10 +105,6 @@ inline std::wstring build_args(const std::wstring & exe, std::vector<std::wstrin
arg += '"';
}
}
else
{
arg = L"\"\"";
}
if (!st.empty())//first one does not need a preceding space
st += L' ';

View File

@@ -263,7 +263,7 @@ public:
auto st1 = key + ::boost::process::detail::equal_sign<Char>();
while (*p != nullptr)
{
const std::size_t len = std::char_traits<Char>::length(*p);
const std::ptrdiff_t len = std::char_traits<Char>::length(*p);
if ((std::distance(st1.begin(), st1.end()) < len)
&& std::equal(st1.begin(), st1.end(), *p))
break;

View File

@@ -1805,7 +1805,6 @@ struct process_environment
}
BOOST_PROCESS_V2_DECL
error_code on_setup(posix::default_launcher & launcher,
const filesystem::path &, const char * const *);
@@ -1887,8 +1886,6 @@ struct hash<BOOST_PROCESS_V2_NAMESPACE::environment::key_value_pair>
#if defined(BOOST_PROCESS_V2_HEADER_ONLY)
#include <boost/process/v2/impl/environment.ipp>
#include <boost/process/v2/detail/impl/environment.ipp>
#endif

View File

@@ -30,6 +30,7 @@ BOOST_AUTO_TEST_CASE(empty, *boost::unit_test::timeout(5))
BOOST_CHECK(ev.empty());
BOOST_CHECK_EQUAL(ev.size(), 0u);
BOOST_CHECK_EQUAL(ev.end() - ev.begin(), 0);
auto nh = ev.native_handle();
ev["Thingy"] = "My value";
BOOST_CHECK(!ev.empty());