QueryData genProcessMemoryMap(QueryContext& context) { QueryData results; auto pidlist = getProcList(context); for (const auto &pid : pidlist) { genProcessMemoryMap(pid, results); } return results; }
static std::string getProcPath(int pid) { char path[PROC_PIDPATHINFO_MAXSIZE] = {0}; int bufsize = proc_pidpath(pid, path, sizeof(path)); if (bufsize <= 0) { if (getuid() == 0) { QueryData memory_map; genProcessMemoryMap(pid, memory_map, true); if (memory_map.size() > 0) { return memory_map[0]["path"]; } } path[0] = '\0'; } return std::string(path); }