Skip to content

Commit

Permalink
Solaris Fixes (#425)
Browse files Browse the repository at this point in the history
* solaris fixes
  • Loading branch information
time-killer-games authored Nov 8, 2024
1 parent 58586e4 commit f3f5ed5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/boost/process/v2/posix/default_launcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <unistd.h>


#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

Expand Down
2 changes: 1 addition & 1 deletion src/ext/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 7 additions & 6 deletions src/pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#endif

#if defined(__sun)
#include <fcntl.h>
#include <sys/types.h>
#include <kvm.h>
#include <sys/param.h>
Expand Down Expand Up @@ -710,9 +711,9 @@ std::vector<pid_type> 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);
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -767,17 +768,17 @@ std::vector<pid_type> child_pids(pid_type pid, boost::system::error_code & ec)
}
};

std::unique_ptr<kvm_t, closer> kd{kvm_open(nullptr, nullptr, nullptr, O_RDONLY, nullptr);
std::unique_ptr<kvm_t, closer> 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);
}
Expand Down

0 comments on commit f3f5ed5

Please sign in to comment.