comparison dep/animia/src/fd/libutil.cc @ 202:71832ffe425a

animia: re-add kvm fd source this is all being merged from my wildly out-of-date laptop. SORRY! in other news, I edited the CI file to install the wayland client as well, so the linux CI build might finally get wayland stuff.
author Paper <paper@paper.us.eu.org>
date Tue, 02 Jan 2024 06:05:06 -0500
parents bc1ae1810855
children
comparison
equal deleted inserted replaced
201:8f6f8dd2eb23 202:71832ffe425a
17 static bool IsSystemFile(const std::string& file) { 17 static bool IsSystemFile(const std::string& file) {
18 return (!file.find("/usr") || !file.find("/lib") || !file.find("/dev") || 18 return (!file.find("/usr") || !file.find("/lib") || !file.find("/dev") ||
19 !file.find("/proc")); 19 !file.find("/proc"));
20 } 20 }
21 21
22 bool LibutilFdTools::EnumerateOpenProcesses(process_proc_t process_proc) { 22 bool EnumerateOpenProcesses(process_proc_t process_proc) {
23 static const int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0}; 23 static const int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
24 size_t length = 0; 24 size_t length = 0;
25 25
26 sysctl((int*)mib, (sizeof(mib) / sizeof(*mib)) - 1, NULL, &length, NULL, 0); 26 sysctl((int*)mib, (sizeof(mib) / sizeof(*mib)) - 1, NULL, &length, NULL, 0);
27 27
45 return false; 45 return false;
46 46
47 return true; 47 return true;
48 } 48 }
49 49
50 bool LibutilFdTools::EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { 50 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) {
51 for (const auto& pid : pids) { 51 for (const auto& pid : pids) {
52 int cnt; 52 int cnt;
53 std::unique_ptr<struct kinfo_file[]> files; 53 std::unique_ptr<struct kinfo_file[]> files;
54 files.reset(kinfo_getfile(pid, &cnt)); 54 files.reset(kinfo_getfile(pid, &cnt));
55 if (!files.get()) 55 if (!files.get())