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

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Dec 2 08:57:00 GMT 2019


On Nov 30 22:58, Anton Lavrentiev via cygwin-patches wrote:
> Fix to prior commit 5fa9a0e7 to address https://cygwin.com/ml/cygwin/2019-08/msg00082.html
> ---
>  winsup/cygwin/fhandler_process.cc | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
> index 9527fea7d..6fc3476b2 100644
> --- a/winsup/cygwin/fhandler_process.cc
> +++ b/winsup/cygwin/fhandler_process.cc
> @@ -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 "
> @@ -1169,7 +1170,7 @@ format_process_stat (void *data, char *&destbuf)
>  			  p->pid, cmd, state,
>  			  p->ppid, p->pgid, p->sid, p->ctty, -1,
>  			  0, fault_count, fault_count, 0, 0, utime, stime,
> -                         utime, stime, NZERO + nice, nice, 0, 0,
> +			  utime, stime, NZERO + nice, nice, 0, 0,
>  			  start_time, vmsize,
>  			  vmrss, vmmaxrss
>  			  );
> -- 
> 2.21.0

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20191202/f3217aaa/attachment.sig>


More information about the Cygwin-patches mailing list