Skip to content

Commit

Permalink
Set ENOTSUP when PROC_PPID_ONLY is undefined
Browse files Browse the repository at this point in the history
closes #452
  • Loading branch information
klemens-morgenstern committed Jan 26, 2025
1 parent a2d2753 commit 0ca663c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ pid_type parent_pid(pid_type pid, error_code & ec)
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)
Expand All @@ -186,6 +188,9 @@ std::vector<pid_type> child_pids(pid_type pid, error_code & ec)
return {};
}
vec.resize(sz);
#else
BOOST_PROCESS_V2_ASSIGN_EC(ec, ENOTSUP, system_category());
#endif
return vec;
}

Expand Down

0 comments on commit 0ca663c

Please sign in to comment.