From 87d44bc8eaa4b2d26184ecff05abf465d7fd71aa Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Sat, 24 Aug 2024 03:41:27 -0400 Subject: [PATCH] Fix building on OpenBSD OpenBSD does not have close_range() nor does NetBSD. OpenBSD needs environ like the other *BSD's. The build was erroring on kp_pid, it looks like p_pid is appropriate. --- include/boost/process/v2/posix/default_launcher.hpp | 2 +- src/pid.cpp | 4 ++-- src/posix/close_handles.cpp | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/boost/process/v2/posix/default_launcher.hpp b/include/boost/process/v2/posix/default_launcher.hpp index 9cfec4b2a..3645f9cba 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(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__MACH__) extern "C" { extern char **environ; } #endif diff --git a/src/pid.cpp b/src/pid.cpp index f32df9ecc..5f29ea36c 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..11ed214b9 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 @@ -219,4 +218,4 @@ void close_all(const std::vector & whitelist, error_code & ec) BOOST_PROCESS_V2_END_NAMESPACE -#endif \ No newline at end of file +#endif