mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48:29 +00:00
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:
parent
27bc49034c
commit
1ff1854107
4 changed files with 111 additions and 44 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue