From c7bfe991242290c154aaebf4aace0350df435d5a Mon Sep 17 00:00:00 2001 From: Samuel Venable Date: Thu, 26 Sep 2024 22:14:18 -0600 Subject: [PATCH] Initial Commit --- include/boost/process/v2/posix/default_launcher.hpp | 2 +- src/ext/cmd.cpp | 4 ++-- src/pid.cpp | 4 ++-- src/posix/close_handles.cpp | 3 +-- src/shell.cpp | 6 +++--- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/boost/process/v2/posix/default_launcher.hpp b/include/boost/process/v2/posix/default_launcher.hpp index 9cfec4b2a..09f8ce428 100644 --- a/include/boost/process/v2/posix/default_launcher.hpp +++ b/include/boost/process/v2/posix/default_launcher.hpp @@ -29,7 +29,7 @@ #include -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) +#if defined(__APPLE__) || defined(__MACH__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) extern "C" { extern char **environ; } #endif diff --git a/src/ext/cmd.cpp b/src/ext/cmd.cpp index d74a06ef4..58e16db5e 100644 --- a/src/ext/cmd.cpp +++ b/src/ext/cmd.cpp @@ -343,7 +343,7 @@ shell cmd(boost::process::v2::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) return vec;} + if (!kd.get()) {BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) return {};} if ((proc_info = kvm_getprocs(kd.get(), KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &cntp))) { char **cmd = kvm_getargv(kd.get(), proc_info, 0); @@ -354,7 +354,7 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) } else BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) - kvm_close(kd); + kvm_close(kd.get()); return {}; } diff --git a/src/pid.cpp b/src/pid.cpp index f32df9ecc..574a38cf7 100644 --- a/src/pid.cpp +++ b/src/pid.cpp @@ -551,9 +551,9 @@ std::vector all_pids(boost::system::error_code & ec) vec.reserve(cntp); for (int i = cntp - 1; i >= 0; i--) { - if (proc_info[i].kp_pid >= 0) + if (proc_info[i].p_pid >= 0) { - vec.push_back(proc_info[i].kp_pid); + vec.push_back(proc_info[i].p_pid); } } } diff --git a/src/posix/close_handles.cpp b/src/posix/close_handles.cpp index 39d63e6dd..67b6381d4 100644 --- a/src/posix/close_handles.cpp +++ b/src/posix/close_handles.cpp @@ -17,10 +17,9 @@ // linux has close_range since 5.19 -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) // https://www.freebsd.org/cgi/man.cgi?query=close_range&apropos=0&sektion=0&manpath=FreeBSD+13.1-RELEASE+and+Ports&arch=default&format=html -// https://man.netbsd.org/closefrom.3 // __FreeBSD__ // // gives us diff --git a/src/shell.cpp b/src/shell.cpp index 0fffc501a..a03d30096 100644 --- a/src/shell.cpp +++ b/src/shell.cpp @@ -19,7 +19,7 @@ #if defined(BOOST_PROCESS_V2_WINDOWS) #include #include -#else +#elif defined(__OpenBSD__) #include #endif @@ -30,7 +30,7 @@ BOOST_PROCESS_V2_DECL const error_category& get_shell_category() { return system_category(); } -#else +#elif defined(__OpenBSD__) struct shell_category_t final : public error_category { @@ -92,7 +92,7 @@ auto shell::args() const-> args_type return input_.c_str(); } -#else +#elif defined(__OpenBSD__) void shell::parse_() {