Fix rusage memory reporting on NT

This issue was caused by c23b6ecc3 a few days ago, where we started
polling that information for the first time.
This commit is contained in:
Justine Tunney 2022-03-31 17:07:22 -07:00
parent 27bc49034c
commit 1ff1854107
4 changed files with 111 additions and 44 deletions

View file

@ -41,13 +41,14 @@ textwindows int sys_getrusage_nt(int who, struct rusage *usage) {
if ((who == RUSAGE_SELF ? GetProcessTimes : GetThreadTimes)(
(who == RUSAGE_SELF ? GetCurrentProcess : GetCurrentThread)(),
&CreationFileTime, &ExitFileTime, &KernelFileTime, &UserFileTime)) {
/* xxx: shouldn't clobber memory on failure below */
usage->ru_utime = WindowsDurationToTimeVal(ReadFileTime(UserFileTime));
usage->ru_stime = WindowsDurationToTimeVal(ReadFileTime(KernelFileTime));
} else {
return __winerr();
}
if (GetProcessMemoryInfo(GetCurrentProcess(), &memcount, sizeof(memcount))) {
usage->ru_maxrss = memcount.PeakWorkingSetSize;
usage->ru_maxrss = memcount.PeakWorkingSetSize / 1024;
usage->ru_majflt = memcount.PageFaultCount;
} else {
return __winerr();