mirror of
https://github.com/boostorg/process.git
synced 2026-01-20 16:52:14 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9c13ff581 | ||
|
|
a7e4fe99c1 | ||
|
|
f9fd327546 | ||
|
|
f372a9a119 | ||
|
|
921bd599b2 | ||
|
|
3999facdd3 | ||
|
|
0ea2eaed27 | ||
|
|
677d94f3a2 | ||
|
|
b8b8d27ac5 | ||
|
|
15555b9664 | ||
|
|
09555dac5f | ||
|
|
818e11672e | ||
|
|
06946018d6 |
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
@@ -23,19 +23,19 @@ jobs:
|
||||
include:
|
||||
- { toolset: gcc-5, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: g++-5 }
|
||||
- { toolset: gcc-6, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: g++-6 }
|
||||
- { toolset: gcc-7, cxxstd: "11,14,17", os: ubuntu-20.04, install: g++-7 }
|
||||
- { toolset: gcc-7, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: g++-7 }
|
||||
- { toolset: gcc-10, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: g++-10 }
|
||||
- { toolset: gcc-12, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: g++-12 }
|
||||
- { toolset: clang, compiler: clang++-3.9, cxxstd: "11,14", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-3.9 }
|
||||
- { toolset: clang, compiler: clang++-4.0, cxxstd: "11,14", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-4.0 }
|
||||
- { toolset: clang, compiler: clang++-5.0, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-5.0 }
|
||||
- { toolset: clang, compiler: clang++-6.0, cxxstd: "11,14,17", os: ubuntu-20.04, install: clang-6.0 }
|
||||
- { toolset: clang, compiler: clang++-7, cxxstd: "11,14,17", os: ubuntu-20.04, install: clang-7 }
|
||||
- { toolset: clang, compiler: clang++-8, cxxstd: "11,14,17", os: ubuntu-20.04, install: clang-8 }
|
||||
- { toolset: clang, compiler: clang++-9, cxxstd: "11,14,17,2a", os: ubuntu-20.04, install: clang-9 }
|
||||
- { toolset: clang, compiler: clang++-10, cxxstd: "11,14,17,2a", os: ubuntu-20.04, install: clang-10 }
|
||||
- { toolset: clang, compiler: clang++-11, cxxstd: "11,14,17,2a", os: ubuntu-20.04, install: clang-11 }
|
||||
- { toolset: clang, compiler: clang++-12, cxxstd: "11,14,17,2a", os: ubuntu-20.04, install: clang-12 }
|
||||
- { toolset: clang, compiler: clang++-6.0, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-6.0 }
|
||||
- { toolset: clang, compiler: clang++-7, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-7 }
|
||||
- { toolset: clang, compiler: clang++-8, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-8 }
|
||||
- { toolset: clang, compiler: clang++-9, cxxstd: "11,14,17,2a", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-9 }
|
||||
- { toolset: clang, compiler: clang++-10, cxxstd: "11,14,17,2a", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-10 }
|
||||
- { toolset: clang, compiler: clang++-11, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: clang-11 }
|
||||
- { toolset: clang, compiler: clang++-12, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: clang-12 }
|
||||
- { toolset: clang, compiler: clang++-13, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: clang-13 }
|
||||
- { toolset: clang, compiler: clang++-14, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: clang-14 }
|
||||
- { toolset: clang, cxxstd: "11,14,17,2a", os: macos-13 }
|
||||
|
||||
@@ -8,6 +8,6 @@ A special thank you goes to [http://www.intra2net.com/(Intra2net AG) (especially
|
||||
|
||||
Great thanks also goes to Boris Schaeling, who despite having boost.process rejected, went on to work on it and maintained it up until this day and participated in the development of the current version.
|
||||
|
||||
Many Thanks, to [https://github.com/time-killer-games](Samuel Venable) for contributing the <<v2::ext>> functionality and all the research that went into it.
|
||||
Many Thanks, to [https://github.com/samuelvenable](Samuel Venable) for contributing the <<v2::ext>> functionality and all the research that went into it.
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
=== `environment`
|
||||
|
||||
The `environment` header provides facilities to maniuplate the current environment and set it for new processes.
|
||||
The `environment` header provides facilities to manipulate the current environment and set it for new processes.
|
||||
|
||||
|
||||
An environment is a a `range` of `T` fulfilling these requirements:
|
||||
@@ -22,7 +22,7 @@ namespace environment
|
||||
// A char traits type that reflects the OS rules for string representing environment keys.
|
||||
/* Can be an alias of std::char_traits. May only be defined for `char` and `wchar_t`.
|
||||
*
|
||||
* Windows treats keys as case-insensitive yet perserving. The char traits are made to reflect
|
||||
* Windows treats keys as case-insensitive yet preserving. The char traits are made to reflect
|
||||
* that behaviour.
|
||||
*/
|
||||
template<typename Char>
|
||||
|
||||
@@ -13,7 +13,7 @@ The major changes are
|
||||
* separate compilation
|
||||
* fd safe by default
|
||||
|
||||
Version 2 is now the defauled. In order to discourage usage of the deprecated v1, it's documentation has been removed.
|
||||
Version 2 is now the default. In order to discourage usage of the deprecated v1, it's documentation has been removed.
|
||||
|
||||
== Simplified Interface
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ io_context ios;
|
||||
child c("ls", ios, on_exit=[](int exit, const std::error_code& ec_in){});
|
||||
|
||||
std::future<int> exit_code;
|
||||
chlid c2("ls", ios, on_exit=exit_code);
|
||||
child c2("ls", ios, on_exit=exit_code);
|
||||
|
||||
\endcode
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 {
|
||||
#if defined(BOOST_PROCESS_DOXYGEN)
|
||||
|
||||
|
||||
/** Class implementing an asnychronous I/O-Object for use with boost.asio.
|
||||
/** Class implementing an asynchronous I/O-Object for use with boost.asio.
|
||||
* It is based on the corresponding I/O Object, that is either boost::asio::windows::stream_handle or
|
||||
* boost::asio::posix::stream_descriptor.
|
||||
*
|
||||
|
||||
@@ -128,7 +128,7 @@ class child
|
||||
/** Same as valid, for convenience. */
|
||||
explicit operator bool() const;
|
||||
|
||||
/** Check if the the chlid process is in any process group. */
|
||||
/** Check if the the child process is in any process group. */
|
||||
bool in_group() const;
|
||||
|
||||
/** \overload bool in_group() const */
|
||||
|
||||
@@ -319,7 +319,7 @@ struct basic_process_handle_signal
|
||||
}
|
||||
|
||||
template<typename Self>
|
||||
void operator()(Self &&self, error_code ec, int sig)
|
||||
void operator()(Self &&self, error_code ec, int /*sig*/)
|
||||
{
|
||||
if (ec == net::error::operation_aborted &&
|
||||
self.get_cancellation_state().cancelled()
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace environment
|
||||
/// A char traits type that reflects the OS rules for string representing environment keys.
|
||||
/** Can be an alias of std::char_traits. May only be defined for `char` and `wchar_t`.
|
||||
*
|
||||
* Windows treats keys as case-insensitive yet perserving. The char traits are made to reflect
|
||||
* Windows treats keys as case-insensitive yet preserving. The char traits are made to reflect
|
||||
* that behaviour.
|
||||
*/
|
||||
template<typename Char>
|
||||
@@ -1372,6 +1372,8 @@ struct current_view
|
||||
environment::native_iterator iterator_;
|
||||
};
|
||||
|
||||
using const_iterator = iterator;
|
||||
|
||||
iterator begin() const {return iterator(handle_.get());}
|
||||
iterator end() const {return iterator(detail::find_end(handle_.get()));}
|
||||
|
||||
|
||||
@@ -355,8 +355,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
net::post(handle.get_executor(),
|
||||
completer{static_cast<int>(res), std::move(self)});
|
||||
net::post(handle.get_executor(), completer{static_cast<int>(res), std::move(self)});
|
||||
}
|
||||
else
|
||||
handle.async_wait(std::move(self));
|
||||
@@ -371,7 +370,10 @@ private:
|
||||
{
|
||||
if (!ec)
|
||||
res = code;
|
||||
std::move(self).complete(ec, evaluate_exit_code(code));
|
||||
else if (ec == boost::system::errc::no_child_process)
|
||||
std::move(self).complete({}, evaluate_exit_code(res));
|
||||
else
|
||||
std::move(self).complete(ec, evaluate_exit_code(code));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -130,8 +130,8 @@ struct process_io_binding
|
||||
|
||||
|
||||
template<typename ReadablePipe>
|
||||
process_io_binding(ReadablePipe & readable_pipe,
|
||||
typename std::enable_if<is_readable_pipe<ReadablePipe>::value && Target != STDIN_FILENO>::type * = nullptr)
|
||||
process_io_binding(ReadablePipe & pipe,
|
||||
typename std::enable_if<is_readable_pipe<ReadablePipe>::value && Target != STD_INPUT_HANDLE>::type * = nullptr)
|
||||
{
|
||||
net::detail::native_pipe_handle p[2];
|
||||
error_code ec;
|
||||
@@ -145,8 +145,8 @@ struct process_io_binding
|
||||
|
||||
|
||||
template<typename WritablePipe>
|
||||
process_io_binding(WritablePipe & writable_pipe,
|
||||
typename std::enable_if<is_writable_pipe<WritablePipe>::value && Target == STDIN_FILENO>::type * = nullptr)
|
||||
process_io_binding(WritablePipe & pipe,
|
||||
typename std::enable_if<is_writable_pipe<WritablePipe>::value && Target == STD_INPUT_HANDLE>::type * = nullptr)
|
||||
{
|
||||
net::detail::native_pipe_handle p[2];
|
||||
error_code ec;
|
||||
@@ -267,7 +267,7 @@ struct process_io_binding
|
||||
return ec;
|
||||
}
|
||||
|
||||
error_code on_exec_setup(posix::default_launcher & launcher,
|
||||
error_code on_exec_setup(posix::default_launcher &,
|
||||
const filesystem::path &, const char * const *)
|
||||
{
|
||||
if (::dup2(fd, target) == -1)
|
||||
|
||||
@@ -109,7 +109,7 @@ inline std::false_type probe_on_error(
|
||||
|
||||
template<typename Launcher, typename Init>
|
||||
inline auto probe_on_error(Launcher & launcher, Init && init, derived && )
|
||||
-> std::is_same<error_code, decltype(init.on_error(launcher, std::declval<const filesystem::path &>(), std::declval<std::wstring &>(), std::declval<std::error_code&>()))>;
|
||||
-> std::is_same<error_code, decltype(init.on_error(launcher, std::declval<const filesystem::path &>(), std::declval<std::wstring &>(), std::declval<error_code&>()))>;
|
||||
|
||||
template<typename Launcher, typename Init>
|
||||
using has_on_error = decltype(probe_on_error(std::declval<Launcher&>(), std::declval<Init>(), derived{}));
|
||||
|
||||
@@ -54,6 +54,8 @@ std::size_t size_as_utf8(const wchar_t * in, std::size_t size, error_code & ec)
|
||||
|
||||
std::size_t size_as_wide(const char * in, std::size_t size, error_code & ec)
|
||||
{
|
||||
if (size == 0u)
|
||||
return 0u;
|
||||
auto res = ::MultiByteToWideChar(
|
||||
CP_UTF8, // CodePage
|
||||
0, // dwFlags
|
||||
@@ -88,6 +90,8 @@ std::size_t convert_to_utf8(const wchar_t *in, std::size_t size, char * out,
|
||||
std::size_t convert_to_wide(const char *in, std::size_t size, wchar_t * out,
|
||||
std::size_t max_size, error_code & ec)
|
||||
{
|
||||
if (size == 0u)
|
||||
return 0u;
|
||||
auto res = ::MultiByteToWideChar(
|
||||
CP_UTF8, // CodePage
|
||||
0, // dwFlags
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(__linux__) || defined(__ANDROID__))
|
||||
#if (defined(__linux__) || defined(__ANDROID__) || defined(__gnu_hurd__))
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
@@ -211,7 +211,7 @@ shell cmd(boost::process::v2::pid_type pid, error_code & ec)
|
||||
return make_cmd_shell_::make(std::move(procargs), argc, argv.release(), fr_func);
|
||||
}
|
||||
|
||||
#elif (defined(__linux__) || defined(__ANDROID__))
|
||||
#elif (defined(__linux__) || defined(__ANDROID__) || defined(__gnu_hurd__))
|
||||
|
||||
shell cmd(boost::process::v2::pid_type pid, error_code & ec)
|
||||
{
|
||||
@@ -403,10 +403,10 @@ shell cmd(boost::process::v2::pid_type pid, error_code & ec)
|
||||
}
|
||||
|
||||
#else
|
||||
filesystem::path cmd(boost::process::v2::pid_type, error_code & ec)
|
||||
shell cmd(boost::process::v2::pid_type, error_code & ec)
|
||||
{
|
||||
BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category());
|
||||
return "";
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ env_view env(boost::process::v2::pid_type pid, error_code & ec)
|
||||
return {};
|
||||
}
|
||||
|
||||
#elif (defined(__APPLE___) || defined(__MACH__)) && !TARGET_OS_IOS
|
||||
#elif (defined(__APPLE__) && defined(__MACH__)) && !TARGET_OS_IOS
|
||||
|
||||
env_view env(boost::process::v2::pid_type pid, error_code & ec)
|
||||
{
|
||||
@@ -309,7 +309,7 @@ env_view env(boost::process::v2::pid_type pid, error_code & ec)
|
||||
return ev;
|
||||
}
|
||||
|
||||
#elif (defined(__linux__) || defined(__ANDROID__))
|
||||
#elif (defined(__linux__) || defined(__ANDROID__)) || defined(__gnu_hurd__)
|
||||
|
||||
env_view env(boost::process::v2::pid_type pid, error_code & ec)
|
||||
{
|
||||
|
||||
10
src/pid.cpp
10
src/pid.cpp
@@ -179,7 +179,6 @@ std::vector<pid_type> child_pids(pid_type pid, error_code & ec)
|
||||
{
|
||||
std::vector<pid_type> vec;
|
||||
#if defined(PROC_PPID_ONLY)
|
||||
|
||||
vec.resize(proc_listpids(PROC_PPID_ONLY, (uint32_t)pid, nullptr, 0) / sizeof(pid_type));
|
||||
const auto sz = proc_listpids(PROC_PPID_ONLY, (uint32_t)pid, &vec[0], sizeof(pid_type) * vec.size());
|
||||
if (sz < 0)
|
||||
@@ -189,7 +188,14 @@ std::vector<pid_type> child_pids(pid_type pid, error_code & ec)
|
||||
}
|
||||
vec.resize(sz);
|
||||
#else
|
||||
BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category());
|
||||
std::vector<pid_type> pids = all_pids(ec);
|
||||
for (std::size_t i = 0; i < pids.size(); i++)
|
||||
{
|
||||
if (pid == parent_pid(pids[i], ec))
|
||||
{
|
||||
vec.push_back(pids[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return vec;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
if (kind == CTRL_CLOSE_EVENT)
|
||||
{
|
||||
// windows doesn't like us doing antyhing else
|
||||
// windows doesn't like us doing anything else
|
||||
::exit(0);
|
||||
if (tim_p != nullptr)
|
||||
tim_p->cancel();
|
||||
|
||||
Reference in New Issue
Block a user