Mercurial > minori
diff dep/animia/src/fd/xnu.cc @ 157:18c8eb5d1edc
x11: make it work
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 16 Nov 2023 16:51:34 -0500 |
parents | cdf79282d647 |
children | 900b5b530883 |
line wrap: on
line diff
--- a/dep/animia/src/fd/xnu.cc Wed Nov 15 18:04:04 2023 -0500 +++ b/dep/animia/src/fd/xnu.cc Thu Nov 16 16:51:34 2023 -0500 @@ -19,13 +19,10 @@ namespace animia::internal::xnu { static std::string GetProcessName(pid_t pid) { - struct proc_bsdinfo proc; + char name[2*MAXCOMLEN]; + proc_name(pid, name, sizeof(name)); - int st = proc_pidinfo(pid, PROC_PIDTBSDINFO, 0, &proc, PROC_PIDTBSDINFO_SIZE); - if (st != PROC_PIDTBSDINFO_SIZE) - return ""; - - return (proc.pbi_name[0]) ? proc.pbi_name : proc.pbi_comm; + return name; } bool XnuFdTools::EnumerateOpenProcesses(process_proc_t process_proc) { @@ -38,8 +35,7 @@ return false; } - for (int i = 0; i < size / sizeof(*pids); i++) { - const pid_t pid = pids[i].kp_proc.p_pid; + for (const auto& pid : pids) { if (!process_proc({pid, GetProcessName(pid)})) return false; }