mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-27 05:12:50 +00:00
research: publish Workstream A memory allocation and resource correctness findings (#473)
Signed-off-by: Arths17 <Atharvranjan8@gmail.com>
This commit is contained in:
1 parent
9ae6d1ee70
commit
8cc2f8ffbc
2536 files changed
+165448
No files matched your search
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Original macOS process accounting observer; native ARM64 only.
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <libproc.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
int main(int argc, char **argv) {
|
||||
if (argc != 2)
|
||||
return 2;
|
||||
rusage_info_v4 r{};
|
||||
int pid = std::atoi(argv[1]);
|
||||
int rc = proc_pid_rusage(pid, RUSAGE_INFO_V4,
|
||||
reinterpret_cast<rusage_info_t *>(&r));
|
||||
std::printf("{\"pid\":%d,\"return\":%d,\"errno\":%d,\"host_page_size\":%d,"
|
||||
"\"phys_footprint\":%llu,\"resident_size\":%llu,\"wired_size\":%"
|
||||
"llu,\"pageins\":%llu,\"max_phys_footprint\":%llu}\n",
|
||||
pid, rc, rc ? errno : 0, getpagesize(), r.ri_phys_footprint,
|
||||
r.ri_resident_size, r.ri_wired_size, r.ri_pageins,
|
||||
r.ri_lifetime_max_phys_footprint);
|
||||
return rc ? 1 : 0;
|
||||
}
|
||||
Reference in new issue
Block a user