mirror of
https://github.com/boostorg/process.git
synced 2026-01-19 04:22:15 +00:00
Support child_pids() Even When PROC_PPID_ONLY is Undefined on Mac
Needs testing...
This commit is contained in:
committed by
Klemens Morgenstern
parent
677d94f3a2
commit
0ea2eaed27
10
src/pid.cpp
10
src/pid.cpp
@@ -179,7 +179,6 @@ std::vector<pid_type> child_pids(pid_type pid, error_code & ec)
|
||||
{
|
||||
std::vector<pid_type> vec;
|
||||
#if defined(PROC_PPID_ONLY)
|
||||
|
||||
vec.resize(proc_listpids(PROC_PPID_ONLY, (uint32_t)pid, nullptr, 0) / sizeof(pid_type));
|
||||
const auto sz = proc_listpids(PROC_PPID_ONLY, (uint32_t)pid, &vec[0], sizeof(pid_type) * vec.size());
|
||||
if (sz < 0)
|
||||
@@ -189,7 +188,14 @@ std::vector<pid_type> child_pids(pid_type pid, error_code & ec)
|
||||
}
|
||||
vec.resize(sz);
|
||||
#else
|
||||
BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category());
|
||||
std::vector<pid_type> pids = all_pids(ec);
|
||||
for (std::size_t i = 0; i < pids.size(); i++)
|
||||
{
|
||||
if (pid == parent_pid(pids[i], ec))
|
||||
{
|
||||
vec.push_back(pids[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return vec;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user