From e47af255342a3485026da303e800bb4d15072372 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Thu, 26 May 2022 17:53:43 +1000 Subject: [PATCH] library: Cygwin only has 4 cpu numbers Old library never checked how many matches there were meaning that both 8-number and 4-number cpu lines would work. --- proc/stat.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proc/stat.c b/proc/stat.c index 147a4224..ac0c2156 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -601,7 +601,11 @@ static int stat_read_failed ( sum_ptr->numa_node = STAT_NODE_INVALID; // mark as invalid // now value the cpu summary tics from line #1 +#ifdef __CYGWIN__ + if (4 > sscanf(bp, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu" +#else if (8 > sscanf(bp, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu" +#endif , &sum_ptr->new.user, &sum_ptr->new.nice, &sum_ptr->new.system , &sum_ptr->new.idle, &sum_ptr->new.iowait, &sum_ptr->new.irq , &sum_ptr->new.sirq, &sum_ptr->new.stolen @@ -630,7 +634,11 @@ reap_em_again: cpu_ptr->numa_node = STAT_NODE_INVALID; cpu_ptr->count = 1; +#ifdef __CYGWIN__ + if (4 > (rc = sscanf(bp, "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu" +#else if (8 > (rc = sscanf(bp, "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu" +#endif , &cpu_ptr->id , &cpu_ptr->new.user, &cpu_ptr->new.nice, &cpu_ptr->new.system , &cpu_ptr->new.idle, &cpu_ptr->new.iowait, &cpu_ptr->new.irq