From f3f5ed53d4c206f929b99aa35d0f43bd9e8ba6c8 Mon Sep 17 00:00:00 2001 From: Samuel Venable Date: Fri, 8 Nov 2024 08:46:21 -0500 Subject: [PATCH] Solaris Fixes (#425) * solaris fixes --- include/boost/process/v2/posix/default_launcher.hpp | 2 +- src/ext/cmd.cpp | 2 +- src/pid.cpp | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/boost/process/v2/posix/default_launcher.hpp b/include/boost/process/v2/posix/default_launcher.hpp index 42a9d6f87..2d372e0b7 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(__APPLE__) || defined(__MACH__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__APPLE__) || defined(__MACH__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun) extern "C" { extern char **environ; } #endif diff --git a/src/ext/cmd.cpp b/src/ext/cmd.cpp index 519a1bc98..14329b4de 100644 --- a/src/ext/cmd.cpp +++ b/src/ext/cmd.cpp @@ -389,7 +389,7 @@ shell cmd(boost::process::v2::pid_type pid, boost::system::error_code & ec) argc++; return make_cmd_shell_::make( {}, argc, cmd, - +[](int, char ** argv) {::free(argv);}) + +[](int, char ** argv) {::free(argv);}); } else BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); diff --git a/src/pid.cpp b/src/pid.cpp index 950ed9467..53af87f4b 100644 --- a/src/pid.cpp +++ b/src/pid.cpp @@ -52,6 +52,7 @@ #endif #if defined(__sun) +#include #include #include #include @@ -710,9 +711,9 @@ std::vector all_pids(boost::system::error_code & ec) BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } - while ((proc_info = kvm_nextproc(kd))) + while ((proc_info = kvm_nextproc(kd.get()))) { - if (kvm_kread(kd, (std::uintptr_t)proc_info->p_pidp, &cur_pid, sizeof(cur_pid)) != -1) + if (kvm_kread(kd.get(), (std::uintptr_t)proc_info->p_pidp, &cur_pid, sizeof(cur_pid)) != -1) { vec.insert(vec.begin(), cur_pid.pid_id); } @@ -744,7 +745,7 @@ pid_type parent_pid(pid_type pid, boost::system::error_code & ec) BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return ppid; } - if ((proc_info = kvm_getproc(kd, pid))) + if ((proc_info = kvm_getproc(kd.get(), pid))) { ppid = proc_info->p_ppid; } @@ -767,17 +768,17 @@ std::vector child_pids(pid_type pid, boost::system::error_code & ec) } }; - std::unique_ptr kd{kvm_open(nullptr, nullptr, nullptr, O_RDONLY, nullptr); + std::unique_ptr kd{kvm_open(nullptr, nullptr, nullptr, O_RDONLY, nullptr)}; if (!kd) { BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec); return vec; } - while ((proc_info = kvm_nextproc(kd))) + while ((proc_info = kvm_nextproc(kd.get()))) { if (proc_info->p_ppid == pid) { - if (kvm_kread(kd, (std::uintptr_t)proc_info->p_pidp, &cur_pid, sizeof(cur_pid)) != -1) + if (kvm_kread(kd.get(), (std::uintptr_t)proc_info->p_pidp, &cur_pid, sizeof(cur_pid)) != -1) { vec.insert(vec.begin(), cur_pid.pid_id); }