comparison dep/animia/src/fd/xnu.cc @ 198:bc1ae1810855

dep/animia: switch from using classes to global functions the old idea was ok, but sort of hackish; this method doesn't use classes at all, and this way (especially important!) we can do wayland stuff AND x11 at the same time, which wasn't really possible without stupid workarounds in the other method
author Paper <mrpapersonic@gmail.com>
date Sun, 24 Dec 2023 02:59:42 -0500
parents e44b7c428d7c
children 2f5a9247e501
comparison
equal deleted inserted replaced
197:c4ca035c565d 198:bc1ae1810855
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <sys/user.h> 15 #include <sys/user.h>
16 16
17 namespace animia::internal::xnu { 17 namespace animia::internal::xnu {
18 18
19 bool XnuFdTools::EnumerateOpenProcesses(process_proc_t process_proc) { 19 bool EnumerateOpenProcesses(process_proc_t process_proc) {
20 size_t pids_size = 512; 20 size_t pids_size = 512;
21 std::unique_ptr<pid_t[]> pids; 21 std::unique_ptr<pid_t[]> pids;
22 22
23 int returned_size = 0; 23 int returned_size = 0;
24 do { 24 do {
36 } 36 }
37 37
38 return true; 38 return true;
39 } 39 }
40 40
41 bool XnuFdTools::EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { 41 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) {
42 if (!open_file_proc) 42 if (!open_file_proc)
43 return false; 43 return false;
44 44
45 for (const auto& pid : pids) { 45 for (const auto& pid : pids) {
46 int bufsz = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0); 46 int bufsz = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0);