[PATCH] Cygwin: proc: Fix loadavg calculation
Takashi Yano
takashi.yano@nifty.ne.jp
Sun Sep 6 11:14:34 GMT 2026
Hi Mark,
Thanks for reviewing!
On Fri, 4 Sep 2026 23:32:26 -0700
Mark Geisert <mark@maxrnd.com> wrote:
> Hi Takashi,
>
> On 9/3/2026 6:24 PM, Takashi Yano wrote:
> > Previously, format_proc_loadavg() wrongly passed an argument `i` to
> > get_process_state(). This should be windows process ID (pids[i]->
> > dwProcessId). This patch fix that.
>
> Nice catch!
>
> > Fixes: 9ca65531e0ed ("* fhandler_proc.cc (format_proc_loadavg): Add running/total processes as fourth component of output.")
> > Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> > Reviewed-by:
> > ---
> > winsup/cygwin/fhandler/proc.cc | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc
> > index f1cd468fc..af3cfdb16 100644
> > --- a/winsup/cygwin/fhandler/proc.cc
> > +++ b/winsup/cygwin/fhandler/proc.cc
> > @@ -442,7 +442,7 @@ format_proc_loadavg (void *, char *&destbuf)
> > winpids pids ((DWORD) 0);
> >
> > for (unsigned i = 0; i < pids.npids; i++)
> > - switch (get_process_state (i)) {
> > + switch (get_process_state (pids[i]->dwProcessId)) {
> > case 'O':
> > case 'R':
> > running++;
>
> The code update LGTM. As an aside, how did you determine the proper
> Fixes: reference? The original code here goes waaaayy back.
I use "git blame" several times and trace back to the commit which
introduce the code having the problem.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
More information about the Cygwin-patches
mailing list