comparison dep/animia/src/fd/linux.cc @ 154:d43d68408d3c

dep/animia: fix XnuFdTools also we use anitomy directly now. HG Enter commit message. Lines beginning with 'HG:' are removed.
author Paper <mrpapersonic@gmail.com>
date Wed, 15 Nov 2023 14:14:17 -0500
parents 8700806c2cc2
children cdf79282d647
comparison
equal deleted inserted replaced
153:bd439dd6ffc5 154:d43d68408d3c
97 } 97 }
98 98
99 return ret.c_str(); 99 return ret.c_str();
100 } 100 }
101 101
102 static bool GetProcessName(pid_t pid, std::string& result) { 102 static std::string GetProcessName(pid_t pid) {
103 const std::string path = PROC_LOCATION "/" + std::to_string(pid) + "/comm"; 103 const std::string path = PROC_LOCATION "/" + std::to_string(pid) + "/comm";
104 104
105 std::string result;
106
105 if (!util::ReadFile(path, result)) 107 if (!util::ReadFile(path, result))
106 return false; 108 return "";
107 109
108 result.erase(std::remove(result.begin(), result.end(), '\n'), result.end()); 110 result.erase(std::remove(result.begin(), result.end(), '\n'), result.end());
109 return true; 111
112 return result;
110 } 113 }
111 114
112 bool LinuxFdTools::EnumerateOpenProcesses(process_proc_t process_proc) { 115 bool LinuxFdTools::EnumerateOpenProcesses(process_proc_t process_proc) {
113 bool success = false; 116 bool success = false;
114 for (const auto& dir : GetAllFilesInDir(PROC_LOCATION)) { 117 for (const auto& dir : GetAllFilesInDir(PROC_LOCATION)) {