diff options
author | Benny Baumann <BenBE@geshi.org> | 2024-03-08 11:09:31 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2024-03-27 20:06:42 +0100 |
commit | 2b7f4a65a8a033c125548c2be17d091a90f1c34f (patch) | |
tree | ae5bf067fef79d42d0a83bd6ab077a4a02e86fbe /linux/LinuxProcessTable.c | |
parent | 0318589c8bc3de6132af7f7d197295f58d89424b (diff) |
Avoid glibc FILE voodoo
Addresses #1408
Diffstat (limited to 'linux/LinuxProcessTable.c')
-rw-r--r-- | linux/LinuxProcessTable.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/linux/LinuxProcessTable.c b/linux/LinuxProcessTable.c index 84308423..b7cc35a4 100644 --- a/linux/LinuxProcessTable.c +++ b/linux/LinuxProcessTable.c @@ -684,13 +684,15 @@ static void LinuxProcessTable_readMaps(LinuxProcess* process, openat_arg_t procF } static bool LinuxProcessTable_readStatmFile(LinuxProcess* process, openat_arg_t procFd, const LinuxMachine* host) { - FILE* statmfile = fopenat(procFd, "statm", "r"); - if (!statmfile) + char statmdata[128] = {0}; + + if (xReadfileat(procFd, "statm", statmdata, sizeof(statmdata)) < 1) { return false; + } long int dummy, dummy2; - int r = fscanf(statmfile, "%ld %ld %ld %ld %ld %ld %ld", + int r = sscanf(statmdata, "%ld %ld %ld %ld %ld %ld %ld", &process->super.m_virt, &process->super.m_resident, &process->m_share, @@ -698,7 +700,6 @@ static bool LinuxProcessTable_readStatmFile(LinuxProcess* process, openat_arg_t &dummy, /* unused since Linux 2.6; always 0 */ &process->m_drs, &dummy2); /* unused since Linux 2.6; always 0 */ - fclose(statmfile); if (r == 7) { process->super.m_virt *= host->pageSizeKB; |