Cygwin: /proc/[PID]/stat to pull process priority correctly

Fix to prior commit 5fa9a0e7 to address https://cygwin.com/ml/cygwin/2019-08/msg00082.html
This commit is contained in:
Anton Lavrentiev via cygwin-patches 2019-11-30 22:58:14 -05:00 committed by Corinna Vinschen
parent c63c29e76e
commit 8574f8a1e4
1 changed files with 3 additions and 2 deletions

View File

@ -1076,6 +1076,7 @@ format_process_stat (void *data, char *&destbuf)
unsigned long fault_count = 0UL,
vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL;
uint64_t utime = 0ULL, stime = 0ULL, start_time = 0ULL;
int nice = 0;
if (p->process_state & PID_EXITED)
strcpy (cmd, "<defunct>");
@ -1138,6 +1139,7 @@ format_process_stat (void *data, char *&destbuf)
if (!NT_SUCCESS (status))
debug_printf ("NtQueryInformationProcess(ProcessQuotaLimits): "
"status %y", status);
nice = winprio_to_nice (GetPriorityClass (hProcess));
CloseHandle (hProcess);
}
status = NtQuerySystemInformation (SystemTimeOfDayInformation,
@ -1157,7 +1159,6 @@ format_process_stat (void *data, char *&destbuf)
vmsize = vmc.PagefileUsage;
vmrss = vmc.WorkingSetSize / page_size;
vmmaxrss = ql.MaximumWorkingSetSize / page_size;
int nice = winprio_to_nice(GetPriorityClass(hProcess));
destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320);
return __small_sprintf (destbuf, "%d (%s) %c "