YDL/RedHat difference in "top"
Bill Fink
yellowdog-general@lists.terrasoftsolutions.com
Sun Aug 4 17:55:01 2002
On Sat Aug 3 2002, Chris Ruprecht wrote:
> I have noticed, that the CPU state line in 'top' is missing in under YDL.=
> Can=20
> anybody explain to me in simple words <grin> why that would be like that?
Hi Chris,
Here is a patch for procps (which contains top) that provides a
workaround for this:
diff -ur procps-2.0.7.dist/top.c procps-2.0.7.mod/top.c
--- procps-2.0.7.dist/top.c Thu Jul 13 16:19:21 2000
+++ procps-2.0.7.mod/top.c Tue Mar 5 01:12:25 2002
@@ -244,6 +244,7 @@
int i;
nr_cpu = sysconf (_SC_NPROCESSORS_ONLN);
+ if (nr_cpu < 1) nr_cpu = 1;
cpu_mapping = (int *) xmalloc (sizeof (int) * nr_cpu);
/* read cpuname */
for (i=0; i< nr_cpu; i++) cpu_mapping[i]=i;
The problem is that on a UP kernel, sysconf (_SC_NPROCESSORS_ONLN)
returns 0. My workaround patch just sets nr_cpu to 1 in this
eventuality and top now works fine for me. Note I am using procps-2.0.7
on a 2.4.19-pre8-ben0 kernel.
-Regards
-Bill