diff --git a/include/boost/process/v2/detail/config.hpp b/include/boost/process/v2/detail/config.hpp index 5337cf8d4..a38c89ed9 100644 --- a/include/boost/process/v2/detail/config.hpp +++ b/include/boost/process/v2/detail/config.hpp @@ -100,9 +100,6 @@ namespace filesystem = std::filesystem; using std::quoted; using std::optional; -#define BOOST_PROCESS_V2_RETURN_EC(ev) \ - return ::BOOST_PROCESS_V2_NAMESPACE::error_code(ev, ::BOOST_PROCESS_V2_NAMESPACE::system_category()); \ - #define BOOST_PROCESS_V2_ASSIGN_EC(ec, ...) ec.assign(__VA_ARGS__); #define BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) \ ec.assign(::BOOST_PROCESS_V2_NAMESPACE::detail::get_last_error()); \ @@ -123,23 +120,21 @@ namespace filesystem = std::filesystem; namespace filesystem = boost::filesystem; #endif -#define BOOST_PROCESS_V2_RETURN_EC(ev) \ -{ \ - static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \ - return ::BOOST_PROCESS_V2_NAMESPACE::error_code(ev, ::BOOST_PROCESS_V2_NAMESPACE::system_category(), &loc##__LINE__); \ -} - #define BOOST_PROCESS_V2_ASSIGN_EC(ec, ...) \ +do \ { \ static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \ ec.assign(__VA_ARGS__, &loc##__LINE__); \ -} +} \ +while (false) #define BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) \ +do \ { \ static constexpr auto loc##__LINE__((BOOST_CURRENT_LOCATION)); \ ec.assign(::BOOST_PROCESS_V2_NAMESPACE::detail::get_last_error(), &loc##__LINE__); \ -} +} \ +while (false) #endif diff --git a/include/boost/process/v2/experimental/basic_stream_input.hpp b/include/boost/process/v2/experimental/basic_stream_input.hpp new file mode 100644 index 000000000..5560b9d06 --- /dev/null +++ b/include/boost/process/v2/experimental/basic_stream_input.hpp @@ -0,0 +1,23 @@ +// +// Copyright (c) 2024 Klemens Morgenstern (klemens.morgenstern@gmx.net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_PROCESS_BASIC_STREAM_INPUT_HPP +#define BOOST_PROCESS_BASIC_STREAM_INPUT_HPP + +#include + +BOOST_PROCESS_V2_BEGIN_NAMESPACE + + + + +template +basic_stream_input open_stdin(Executor executor, bool duplicate = true); + +BOOST_PROCESS_V2_END_NAMESPACE + +#endif //BOOST_PROCESS_BASIC_STREAM_INPUT_HPP diff --git a/include/boost/process/v2/experimental/stream_input.hpp b/include/boost/process/v2/experimental/stream_input.hpp new file mode 100644 index 000000000..000d2d28f --- /dev/null +++ b/include/boost/process/v2/experimental/stream_input.hpp @@ -0,0 +1,21 @@ +// +// Copyright (c) 2024 Klemens Morgenstern (klemens.morgenstern@gmx.net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_PROCESS_V2_EXPERIMENTAL_STREAM_INPUT_HPP +#define BOOST_PROCESS_V2_EXPERIMENTAL_STREAM_INPUT_HPP + +#include +#include + + +BOOST_PROCESS_V2_BEGIN_NAMESPACE + +typedef basic_stream_input<> stream_input; + +BOOST_PROCESS_V2_END_NAMESPACE + +#endif //BOOST_PROCESS_V2_EXPERIMENTAL_STREAM_INPUT_HPP diff --git a/include/boost/process/v2/posix/default_launcher.hpp b/include/boost/process/v2/posix/default_launcher.hpp index 8a856d285..625be154a 100644 --- a/include/boost/process/v2/posix/default_launcher.hpp +++ b/include/boost/process/v2/posix/default_launcher.hpp @@ -365,12 +365,12 @@ struct default_launcher pipe_guard pg; if (::pipe(pg.p)) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); return basic_process{exec}; } if (::fcntl(pg.p[1], F_SETFD, FD_CLOEXEC)) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); return basic_process{exec}; } ec = detail::on_setup(*this, executable, argv, inits ...); @@ -391,7 +391,7 @@ struct default_launcher detail::on_fork_error(*this, executable, argv, ec, inits...); detail::on_error(*this, executable, argv, ec, inits...); - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); return basic_process{exec}; } else if (pid == 0) @@ -407,7 +407,7 @@ struct default_launcher ::execve(executable.c_str(), const_cast(argv), const_cast(env)); ignore_unused(::write(pg.p[1], &errno, sizeof(int))); - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); detail::on_exec_error(*this, executable, argv, ec, inits...); ::exit(EXIT_FAILURE); return basic_process{exec}; @@ -423,12 +423,12 @@ struct default_launcher int err = errno; if ((err != EAGAIN) && (err != EINTR)) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, err, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, err, system_category()); break; } } if (count != 0) - BOOST_PROCESS_V2_ASSIGN_EC(ec, child_error, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, child_error, system_category()); if (ec) { diff --git a/include/boost/process/v2/posix/fork_and_forget_launcher.hpp b/include/boost/process/v2/posix/fork_and_forget_launcher.hpp index 6cf68b52a..ff28eef93 100644 --- a/include/boost/process/v2/posix/fork_and_forget_launcher.hpp +++ b/include/boost/process/v2/posix/fork_and_forget_launcher.hpp @@ -94,7 +94,7 @@ struct fork_and_forget_launcher : default_launcher detail::on_fork_error(*this, executable, argv, ec, inits...); detail::on_error(*this, executable, argv, ec, inits...); - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); return basic_process{exec}; } else if (pid == 0) @@ -107,7 +107,7 @@ struct fork_and_forget_launcher : default_launcher if (!ec) ::execve(executable.c_str(), const_cast(argv), const_cast(env)); - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); detail::on_exec_error(*this, executable, argv, ec, inits...); ::exit(EXIT_FAILURE); return basic_process{exec}; diff --git a/include/boost/process/v2/posix/pdfork_launcher.hpp b/include/boost/process/v2/posix/pdfork_launcher.hpp index 016182734..a00baf4c1 100644 --- a/include/boost/process/v2/posix/pdfork_launcher.hpp +++ b/include/boost/process/v2/posix/pdfork_launcher.hpp @@ -85,12 +85,12 @@ struct pdfork_launcher : default_launcher pipe_guard pg; if (::pipe(pg.p)) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); return basic_process{exec}; } if (::fcntl(pg.p[1], F_SETFD, FD_CLOEXEC)) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); return basic_process{exec}; } ec = detail::on_setup(*this, executable, argv, inits ...); @@ -111,7 +111,7 @@ struct pdfork_launcher : default_launcher detail::on_fork_error(*this, executable, argv, ec, inits...); detail::on_error(*this, executable, argv, ec, inits...); - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); return basic_process{exec}; } else if (pid == 0) @@ -128,7 +128,7 @@ struct pdfork_launcher : default_launcher ::execve(executable.c_str(), const_cast(argv), const_cast(env)); default_launcher::ignore_unused(::write(pg.p[1], &errno, sizeof(int))); - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); detail::on_exec_error(*this, executable, argv, ec, inits...); ::exit(EXIT_FAILURE); return basic_process{exec}; @@ -143,12 +143,12 @@ struct pdfork_launcher : default_launcher int err = errno; if ((err != EAGAIN) && (err != EINTR)) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, err, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, err, system_category()); break; } } if (count != 0) - BOOST_PROCESS_V2_ASSIGN_EC(ec, child_error, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, child_error, system_category()); if (ec) { diff --git a/include/boost/process/v2/posix/vfork_launcher.hpp b/include/boost/process/v2/posix/vfork_launcher.hpp index b9b8b6578..81c0db832 100644 --- a/include/boost/process/v2/posix/vfork_launcher.hpp +++ b/include/boost/process/v2/posix/vfork_launcher.hpp @@ -96,7 +96,7 @@ struct vfork_launcher : default_launcher detail::on_fork_error(*this, executable, argv, ec, inits...); detail::on_error(*this, executable, argv, ec, inits...); - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); return basic_process{exec}; } else if (pid == 0) @@ -107,7 +107,7 @@ struct vfork_launcher : default_launcher if (!ec) ::execve(executable.c_str(), const_cast(argv), const_cast(env)); - BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, errno, system_category()); detail::on_exec_error(*this, executable, argv, ec, inits...); ::_exit(EXIT_FAILURE); return basic_process{exec}; diff --git a/include/boost/process/v2/stdio.hpp b/include/boost/process/v2/stdio.hpp index 4dc92b838..fdc348ca2 100644 --- a/include/boost/process/v2/stdio.hpp +++ b/include/boost/process/v2/stdio.hpp @@ -197,7 +197,7 @@ struct process_io_binding fd = p[1]; if (::fcntl(p[0], F_SETFD, FD_CLOEXEC) == -1) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ; } fd_needs_closing = true; @@ -223,7 +223,7 @@ struct process_io_binding fd = p[0]; if (::fcntl(p[1], F_SETFD, FD_CLOEXEC) == -1) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ; } fd_needs_closing = true; diff --git a/include/boost/process/v2/windows/as_user_launcher.hpp b/include/boost/process/v2/windows/as_user_launcher.hpp index 88f9c2a29..3829a120d 100644 --- a/include/boost/process/v2/windows/as_user_launcher.hpp +++ b/include/boost/process/v2/windows/as_user_launcher.hpp @@ -107,7 +107,7 @@ struct as_user_launcher : default_launcher if (ok == 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); detail::on_error(*this, executable, command_line, ec, inits...); if (process_information.hProcess != INVALID_HANDLE_VALUE) diff --git a/include/boost/process/v2/windows/default_launcher.hpp b/include/boost/process/v2/windows/default_launcher.hpp index 78cbd0cde..7ea8c8472 100644 --- a/include/boost/process/v2/windows/default_launcher.hpp +++ b/include/boost/process/v2/windows/default_launcher.hpp @@ -314,7 +314,7 @@ struct default_launcher if (ok == 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); detail::on_error(*this, executable, command_line, ec, inits...); if (process_information.hProcess != INVALID_HANDLE_VALUE) diff --git a/include/boost/process/v2/windows/with_logon_launcher.hpp b/include/boost/process/v2/windows/with_logon_launcher.hpp index e88722145..a71540cac 100644 --- a/include/boost/process/v2/windows/with_logon_launcher.hpp +++ b/include/boost/process/v2/windows/with_logon_launcher.hpp @@ -111,7 +111,7 @@ struct with_logon_launcher : default_launcher if (ok == 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); detail::on_error(*this, executable, command_line, ec, inits...); if (process_information.hProcess != INVALID_HANDLE_VALUE) diff --git a/include/boost/process/v2/windows/with_token_launcher.hpp b/include/boost/process/v2/windows/with_token_launcher.hpp index a0b23bc41..48efab698 100644 --- a/include/boost/process/v2/windows/with_token_launcher.hpp +++ b/include/boost/process/v2/windows/with_token_launcher.hpp @@ -106,7 +106,7 @@ struct with_token_launcher : default_launcher if (ok == 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); detail::on_error(*this, executable, command_line, ec, inits...); if (process_information.hProcess != INVALID_HANDLE_VALUE) diff --git a/src/detail/environment_posix.cpp b/src/detail/environment_posix.cpp index c3006ca15..7a7913671 100644 --- a/src/detail/environment_posix.cpp +++ b/src/detail/environment_posix.cpp @@ -30,7 +30,7 @@ basic_cstring_ref> get( auto res = ::getenv(key.c_str()); if (res == nullptr) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOENT, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOENT, system_category()); return {}; } return res; @@ -41,13 +41,13 @@ void set(basic_cstring_ref> key, error_code & ec) { if (::setenv(key.c_str(), value.c_str(), true)) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } void unset(basic_cstring_ref> key, error_code & ec) { if (::unsetenv(key.c_str())) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } diff --git a/src/detail/environment_win.cpp b/src/detail/environment_win.cpp index cbd64c6f6..27065192d 100644 --- a/src/detail/environment_win.cpp +++ b/src/detail/environment_win.cpp @@ -45,7 +45,7 @@ std::basic_string> get( buf.resize(size); if (buf.size() == 0) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return buf; } @@ -55,14 +55,14 @@ void set(basic_cstring_ref> key, error_code & ec) { if (!::SetEnvironmentVariableW(key.c_str(), value.c_str())) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } void unset(basic_cstring_ref> key, error_code & ec) { if (!::SetEnvironmentVariableW(key.c_str(), nullptr)) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } @@ -83,7 +83,7 @@ std::basic_string> get( buf.resize(size); if (buf.size() == 0) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return buf; } @@ -93,14 +93,14 @@ void set(basic_cstring_ref> key, error_code & ec) { if (!::SetEnvironmentVariableA(key.c_str(), value.c_str())) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } void unset(basic_cstring_ref> key, error_code & ec) { if (!::SetEnvironmentVariableA(key.c_str(), nullptr)) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } diff --git a/src/detail/process_handle_windows.cpp b/src/detail/process_handle_windows.cpp index fa77e492a..afe821cd8 100644 --- a/src/detail/process_handle_windows.cpp +++ b/src/detail/process_handle_windows.cpp @@ -35,7 +35,7 @@ void get_exit_code_( error_code & ec) { if (!::GetExitCodeProcess(handle, &exit_code)) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } @@ -45,7 +45,7 @@ HANDLE open_process_(DWORD pid) if (proc == nullptr) { error_code ec; - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); throw system_error(ec, "open_process()"); } @@ -67,7 +67,7 @@ bool check_handle_(HANDLE handle, error_code & ec) { if (handle == INVALID_HANDLE_VALUE) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_INVALID_HANDLE_STATE, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_INVALID_HANDLE_STATE, system_category()); return false; } return true; @@ -77,7 +77,7 @@ bool check_pid_(pid_type pid_, error_code & ec) { if (pid_ == 0) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_INVALID_HANDLE_STATE, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_INVALID_HANDLE_STATE, system_category()); return false; } return true; @@ -100,7 +100,7 @@ static BOOL CALLBACK enum_window(HWND hwnd, LPARAM param) LRESULT res = ::SendMessageW(hwnd, WM_CLOSE, 0, 0); if (res) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(data->ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(data->ec); return res == 0; } @@ -109,25 +109,25 @@ void request_exit_(pid_type pid_, error_code & ec) enum_windows_data_t data{ec, pid_}; if (!::EnumWindows(enum_window, reinterpret_cast(&data))) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } void interrupt_(pid_type pid_, error_code & ec) { if (!::GenerateConsoleCtrlEvent(CTRL_C_EVENT, pid_)) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } void terminate_(HANDLE handle, error_code & ec, DWORD & exit_status) { if (!::TerminateProcess(handle, 260)) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } void check_running_(HANDLE handle, error_code & ec, DWORD & exit_status) { if (!::GetExitCodeProcess(handle, &exit_status)) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } #if !defined(BOOST_PROCESS_V2_DISABLE_UNDOCUMENTED_API) @@ -136,7 +136,7 @@ void suspend_(HANDLE handle, error_code & ec) auto nt_err = NtSuspendProcess(handle); ULONG dos_err = RtlNtStatusToDosError(nt_err); if (dos_err) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } void resume_(HANDLE handle, error_code & ec) @@ -144,17 +144,17 @@ void resume_(HANDLE handle, error_code & ec) auto nt_err = NtResumeProcess(handle); ULONG dos_err = RtlNtStatusToDosError(nt_err); if (dos_err) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } #else void suspend_(HANDLE, error_code & ec) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_CALL_NOT_IMPLEMENTED, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_CALL_NOT_IMPLEMENTED, system_category()); } void resume_(HANDLE handle, error_code & ec) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_CALL_NOT_IMPLEMENTED, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_CALL_NOT_IMPLEMENTED, system_category()); } #endif diff --git a/src/detail/utf8.cpp b/src/detail/utf8.cpp index f13a0b6d1..531683e86 100644 --- a/src/detail/utf8.cpp +++ b/src/detail/utf8.cpp @@ -25,13 +25,13 @@ inline void handle_error(error_code & ec) switch (err) { case ERROR_INSUFFICIENT_BUFFER: - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::utf8_category) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::utf8_category); break; case ERROR_NO_UNICODE_TRANSLATION: - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::invalid_character, error::utf8_category) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::invalid_character, error::utf8_category); break; default: - BOOST_PROCESS_V2_ASSIGN_EC(ec, err, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, err, system_category()); } } @@ -240,7 +240,7 @@ std::size_t convert_to_utf8(const wchar_t * in, std::size_t size, if (*from > max_wchar) { from_next = from; to_next = to; - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::invalid_character, error::get_utf8_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::invalid_character, error::get_utf8_category()); return 0u; } @@ -268,7 +268,7 @@ std::size_t convert_to_utf8(const wchar_t * in, std::size_t size, if (to == to_end && i != cont_octet_count) { from_next = from; to_next = to - (i + 1); - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::get_utf8_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::get_utf8_category()); return 0u; } ++from; @@ -278,7 +278,7 @@ std::size_t convert_to_utf8(const wchar_t * in, std::size_t size, // Were we done or did we run out of destination space if (from != from_end) - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::get_utf8_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::get_utf8_category()); return to_next - out; } @@ -313,7 +313,7 @@ std::size_t convert_to_wide(const char * in, std::size_t size, if (invalid_leading_octet(*from)) { from_next = from; to_next = to; - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::invalid_character, error::get_utf8_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::invalid_character, error::get_utf8_category()); return 0u; } @@ -337,7 +337,7 @@ std::size_t convert_to_wide(const char * in, std::size_t size, if (invalid_continuing_octet(*from)) { from_next = from; to_next = to; - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::invalid_character, error::get_utf8_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::invalid_character, error::get_utf8_category()); return 0u; } @@ -354,7 +354,7 @@ std::size_t convert_to_wide(const char * in, std::size_t size, // rewind "from" to before the current character translation from_next = from - (i + 1); to_next = to; - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::get_utf8_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::get_utf8_category()); return 0u; } *to++ = ucs_result; @@ -363,7 +363,7 @@ std::size_t convert_to_wide(const char * in, std::size_t size, to_next = to; if (from != from_end) - BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::get_utf8_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error::insufficient_buffer, error::get_utf8_category()); return to_next - out; } diff --git a/src/ext/cmd.cpp b/src/ext/cmd.cpp index 3a5ea9e3a..a96fd4bbf 100644 --- a/src/ext/cmd.cpp +++ b/src/ext/cmd.cpp @@ -168,7 +168,7 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) auto size = sizeof(argmax); if (sysctl(mib, 2, &argmax, &size, nullptr, 0) == -1) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } @@ -181,7 +181,7 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) if (sysctl(mib, 3, &*procargs.begin(), &size, nullptr, 0) != 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } @@ -198,7 +198,7 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) auto e = std::find(itr, end, '\0'); if (e == end && n < argc) // something off { - BOOST_PROCESS_V2_ASSIGN_EC(ec, EINVAL, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, EINVAL, system_category()); return {}; } argv[n] = &*itr; @@ -223,7 +223,7 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) auto r = ::read(f, &*(procargs.end() - 4096), 4096); if (r < 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); ::close(f); return {}; } @@ -254,7 +254,7 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) auto e = std::find(itr, end, '\0'); if (e == end && n < argc) // something off { - BOOST_PROCESS_V2_ASSIGN_EC(ec, EINVAL, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, EINVAL, system_category()); return {}; } argv[n] = &*itr; @@ -290,10 +290,10 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) if (cmd) return make_cmd_shell_::clone(cmd); else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } @@ -322,10 +322,10 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) if (cmd) return make_cmd_shell_::clone(cmd); else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -353,10 +353,10 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) if (cmd) return make_cmd_shell_::clone(cmd); else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); kvm_close(kd); return {}; } @@ -384,13 +384,13 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) +[](int, char ** argv) {::free(argv);}) } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); kvm_close(kd); return {}; @@ -399,7 +399,7 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) #else filesystem::path cmd(boost::process::v2::pid_type, boost::system::error_code & ec) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category()); return ""; } #endif diff --git a/src/ext/cwd.cpp b/src/ext/cwd.cpp index d9a0dc7aa..2bbc4dc82 100644 --- a/src/ext/cwd.cpp +++ b/src/ext/cwd.cpp @@ -73,7 +73,7 @@ filesystem::path cwd(HANDLE proc, boost::system::error_code & ec) if (!buffer.empty()) return filesystem::canonical(buffer, ec); else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ""; } @@ -88,7 +88,7 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code }; std::unique_ptr proc{detail::ext::open_process_with_debug_privilege(pid, ec)}; if (proc == nullptr) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); else return cwd(proc.get(), ec); return {}; @@ -111,7 +111,7 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code if (proc_pidinfo(pid, PROC_PIDVNODEPATHINFO, 0, &vpi, sizeof(vpi)) > 0) return filesystem::canonical(vpi.pvi_cdir.vip_path, ec); else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ""; } @@ -146,10 +146,10 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code path = filesystem::canonical(kif.kf_path, ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return path; } @@ -166,7 +166,7 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code path = filesystem::canonical(buffer, ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return path; } @@ -192,17 +192,17 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code path = filesystem::canonical(&vecbuff[0], ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return path; } #else filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code & ec) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category()); return ""; } #endif diff --git a/src/ext/env.cpp b/src/ext/env.cpp index bddd8cd71..e7861c6d7 100644 --- a/src/ext/env.cpp +++ b/src/ext/env.cpp @@ -174,19 +174,19 @@ env_view env(HANDLE proc, boost::system::error_code & ec) if (error) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, error, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error, system_category()); return {}; } if (!ReadProcessMemory(proc, pbi.PebBaseAddress, &peb, sizeof(peb), &nRead)) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } if (!ReadProcessMemory(proc, peb.ProcessParameters, &upp, sizeof(upp), &nRead)) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } @@ -197,7 +197,7 @@ env_view env(HANDLE proc, boost::system::error_code & ec) if (!ReadProcessMemory(proc, buf, ev.handle_.get(), len, &nRead)) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } @@ -225,7 +225,7 @@ env_view env(boost::process::v2::pid_type pid, boost::system::error_code & ec) }; std::unique_ptr proc{detail::ext::open_process_with_debug_privilege(pid, ec)}; if (proc == nullptr) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); else return env(proc.get(), ec); @@ -241,7 +241,7 @@ env_view env(boost::process::v2::pid_type pid, boost::system::error_code & ec) auto size = sizeof(argmax); if (sysctl(mib, 2, &argmax, &size, nullptr, 0) == -1) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } @@ -254,7 +254,7 @@ env_view env(boost::process::v2::pid_type pid, boost::system::error_code & ec) if (sysctl(mib, 3, &*procargs.begin(), &size, nullptr, 0) != 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } std::uint32_t nargs; @@ -312,7 +312,7 @@ env_view env(boost::process::v2::pid_type pid, boost::system::error_code & ec) auto r = ::read(f, buf.get() + size, 4096); if (r < 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); ::close(f); return {}; } @@ -379,18 +379,18 @@ env_view env(boost::process::v2::pid_type pid, boost::system::error_code & ec) ev.handle_.reset(eeo); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); } procstat_freeprocs(proc_stat, proc_info); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); procstat_close(proc_stat); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ev; } diff --git a/src/ext/exe.cpp b/src/ext/exe.cpp index 5240d2516..9e6e78eae 100644 --- a/src/ext/exe.cpp +++ b/src/ext/exe.cpp @@ -83,7 +83,7 @@ filesystem::path exe(HANDLE proc, boost::system::error_code & ec) return filesystem::canonical(buffer, ec); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ""; } @@ -109,7 +109,7 @@ filesystem::path exe(boost::process::v2::pid_type pid, boost::system::error_code }; std::unique_ptr proc{detail::ext::open_process_with_debug_privilege(pid, ec)}; if (proc == nullptr) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); else return exe(proc.get(), ec); } @@ -125,7 +125,7 @@ filesystem::path exe(boost::process::v2::pid_type pid, boost::system::error_code { return filesystem::canonical(buffer, ec); } - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ""; } @@ -165,7 +165,7 @@ filesystem::path exe(boost::process::v2::pid_type pid, boost::system::error_code } } - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ""; } @@ -173,14 +173,14 @@ filesystem::path exe(boost::process::v2::pid_type pid, boost::system::error_code filesystem::path exe(boost::process::v2::pid_type pid, boost::system::error_code & ec) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category()); return ""; } #else filesystem::path exe(boost::process::v2::pid_type pid, boost::system::error_code & ec) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category()); return ""; } #endif diff --git a/src/ext/proc_info.cpp b/src/ext/proc_info.cpp index 22bdfa0d8..aef9d1b75 100644 --- a/src/ext/proc_info.cpp +++ b/src/ext/proc_info.cpp @@ -43,19 +43,19 @@ std::wstring cwd_cmd_from_proc(HANDLE proc, int type, boost::system::error_code if (error) { - BOOST_PROCESS_V2_ASSIGN_EC(ec, error, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, error, system_category()); return {}; } if (!ReadProcessMemory(proc, pbi.PebBaseAddress, &peb, sizeof(peb), &nRead)) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } if (!ReadProcessMemory(proc, peb.ProcessParameters, &upp, sizeof(upp), &nRead)) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } @@ -74,7 +74,7 @@ std::wstring cwd_cmd_from_proc(HANDLE proc, int type, boost::system::error_code if (!ReadProcessMemory(proc, buf, &buffer[0], len, &nRead)) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } @@ -107,7 +107,7 @@ HANDLE open_process_with_debug_privilege(boost::process::v2::pid_type pid, boost if (!proc) proc = OpenProcess(PROCESS_ALL_ACCESS, false, pid); if (!proc) - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return proc; } #endif diff --git a/src/pid.cpp b/src/pid.cpp index d6ab609e9..7713b8221 100644 --- a/src/pid.cpp +++ b/src/pid.cpp @@ -74,7 +74,7 @@ std::vector all_pids(boost::system::error_code & ec) HANDLE hp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (!hp) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } PROCESSENTRY32 pe; @@ -96,7 +96,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) HANDLE hp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (!hp) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } PROCESSENTRY32 pe; @@ -123,7 +123,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) HANDLE hp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (!hp) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } PROCESSENTRY32 pe; @@ -152,7 +152,7 @@ std::vector all_pids(boost::system::error_code & ec) const auto sz = proc_listpids(PROC_ALL_PIDS, 0, &vec[0], sizeof(pid_type) * vec.size()); if (sz < 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } vec.resize(sz); @@ -165,7 +165,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) proc_bsdinfo proc_info; if (proc_pidinfo(pid, PROC_PIDTBSDINFO, 0, &proc_info, sizeof(proc_info)) <= 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } else @@ -180,7 +180,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) const auto sz = proc_listpids(PROC_PPID_ONLY, (uint32_t)pid, &vec[0], sizeof(pid_type) * vec.size()); if (sz < 0) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return {}; } vec.resize(sz); @@ -195,7 +195,7 @@ std::vector all_pids(boost::system::error_code & ec) DIR *proc = opendir("/proc"); if (!proc) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } struct dirent *ent = nullptr; @@ -218,9 +218,9 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) if (!stat) { if (errno == ENOENT) - BOOST_PROCESS_V2_ASSIGN_EC(ec, ESRCH, system_category()) + BOOST_PROCESS_V2_ASSIGN_EC(ec, ESRCH, system_category()); else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } else @@ -245,7 +245,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) if (!token) { fclose(stat); - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } } @@ -286,7 +286,7 @@ std::vector all_pids(boost::system::error_code & ec) free(proc_info); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -300,7 +300,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) free(proc_info); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } @@ -322,7 +322,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) free(proc_info); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -346,7 +346,7 @@ std::vector all_pids(boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nlistf, memf, nullptr, O_RDONLY, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } if ((proc_info = kvm_getprocs(kd.get(), KERN_PROC_ALL, 0, &cntp))) @@ -357,7 +357,7 @@ std::vector all_pids(boost::system::error_code & ec) vec.push_back(proc_info[i].kp_pid); } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -379,7 +379,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nlistf, memf, nullptr, O_RDONLY, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } if ((proc_info = kvm_getprocs(kd.get(), KERN_PROC_PID, pid, &cntp))) @@ -390,7 +390,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) } } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } @@ -412,7 +412,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nlistf, memf, nullptr, O_RDONLY, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } if ((proc_info = kvm_getprocs(kd.get(), KERN_PROC_ALL, 0, &cntp))) @@ -427,7 +427,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) } } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -449,7 +449,7 @@ std::vector all_pids(boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } if ((proc_info = kvm_getproc2(kd.get(), KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), &cntp))) @@ -461,7 +461,7 @@ std::vector all_pids(boost::system::error_code & ec) } } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -481,7 +481,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } if ((proc_info = kvm_getproc2(kd.get(), KERN_PROC_PID, pid, sizeof(struct kinfo_proc2), &cntp))) @@ -489,7 +489,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) ppid = proc_info->p_ppid; } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } @@ -509,7 +509,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } if ((proc_info = kvm_getproc2(kd.get(), KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), &cntp))) @@ -524,7 +524,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) } } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -546,7 +546,7 @@ std::vector all_pids(boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } if ((proc_info = kvm_getprocs(kd.get(), KERN_PROC_ALL, 0, sizeof(struct kinfo_proc), &cntp))) @@ -561,7 +561,7 @@ std::vector all_pids(boost::system::error_code & ec) } } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -581,7 +581,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } if ((proc_info = kvm_getprocs(kd.get(), KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &cntp))) @@ -589,7 +589,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) ppid = proc_info->p_ppid; } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } @@ -609,7 +609,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) std::unique_ptr kd{kvm_openfiles(nullptr, nullptr, nullptr, KVM_NO_FILES, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } if ((proc_info = kvm_getprocs(kd.get(), KERN_PROC_ALL, 0, sizeof(struct kinfo_proc), &cntp))) @@ -624,7 +624,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) } } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } @@ -647,7 +647,7 @@ std::vector all_pids(boost::system::error_code & ec) std::unique_ptr kd{kvm_open(nullptr, nullptr, nullptr, O_RDONLY, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } while ((proc_info = kvm_nextproc(kd))) @@ -658,7 +658,7 @@ std::vector all_pids(boost::system::error_code & ec) } else { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); break; } } @@ -680,7 +680,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) std::unique_ptr kd{kvm_open(nullptr, nullptr, nullptr, O_RDONLY, nullptr)}; if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } if ((proc_info = kvm_getproc(kd, pid))) @@ -688,7 +688,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) ppid = proc_info->p_ppid; } else - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } @@ -708,7 +708,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) std::unique_ptr kd{kvm_open(nullptr, nullptr, nullptr, O_RDONLY, nullptr); if (!kd) { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } while ((proc_info = kvm_nextproc(kd))) @@ -721,7 +721,7 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) } else { - BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); break; } }