On 2018/10/04 08:04, Okan Demirmen wrote:
> I chose the minimal route; basically if one gets ENODEV back, the values
> for the unavailable cpus will be 0.
> 
> I don't use xstatbar, but is this an acceptable direction?
> 
> Thanks.
> 
> Index: Makefile
> ===================================================================
> RCS file: /home/open/cvs/ports/sysutils/xstatbar/Makefile,v
> retrieving revision 1.19
> diff -u -p -r1.19 Makefile
> --- Makefile  1 Jun 2018 14:20:19 -0000       1.19
> +++ Makefile  4 Oct 2018 11:56:06 -0000
> @@ -5,7 +5,7 @@ ONLY_FOR_ARCHS=       ${APM_ARCHS}
>  COMMENT=     simple system monitor bar
>  
>  DISTNAME=    xstatbar-0.5
> -REVISION=    9
> +REVISION=    10
>  FIX_EXTRACT_PERMISSIONS=Yes
>  
>  CATEGORIES=  sysutils x11
> Index: patches/patch-stats_c
> ===================================================================
> RCS file: /home/open/cvs/ports/sysutils/xstatbar/patches/patch-stats_c,v
> retrieving revision 1.9
> diff -u -p -r1.9 patch-stats_c
> --- patches/patch-stats_c     1 Jun 2018 14:20:19 -0000       1.9
> +++ patches/patch-stats_c     4 Oct 2018 11:57:39 -0000
> @@ -56,7 +56,17 @@ Index: stats.c
>   
>      /* get swap status */
>      if ((nswaps = swapctl(SWAP_NSWAP, 0, 0)) == 0)
> -@@ -509,9 +520,9 @@ int
> +@@ -459,7 +470,8 @@ sysinfo_update()
> +       for (cpu = 0; cpu < sysinfo.ncpu; cpu++) {
> +          mib_cpus[2] = cpu;
> +          if (sysctl(mib_cpus, 3, sysinfo.cpu_raw[cpu][cur], &size, NULL, 0) 
> < 0)
> +-            err(1, "sysinfo update: KERN.CPTIME2.%d failed", cpu);
> ++              if (errno != ENODEV)
> ++                err(1, "sysinfo update: KERN.CPTIME2.%d failed", cpu);

The sysctl returns ENODEV before filling out the structure, so AIUI we would
need to zero sysinfo.cpu_raw[cpu][cur] at this point because it does not contain
valid data.

Reply via email to