lkml.org 
[lkml]   [1999]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectpre-patch-2.2.2-5 breaks xosview
pre-patch-2.2.2-5 broke xosview on my system (using libc-5.4.46,
libg++-2.7.2.8). xosview started under 2.2.2pre5 just sits in an
infinite loop after reading /proc/stats to count cpus (in
CPUMeter::countCPUs). I think this may be because the "intr"
line in /proc/stats is now longer than 256 characters, and the
buffer used to read lines from /proc/stats in xosview is only 256
characters long, because raising that buffer size in xosview
fixes the problem.

I suppose this can't really be considered a kernel bug, although
it does seem odd that on my system (a 486DX2/66) the intr line in
/proc/stat has 225 numbers on it, most of which are zero as there
are only 16 IRQs.

This is the diff showing what I changed to get xosview working
again.

--- xosview-1.6.1.a/linux/cpumeter.cc.old Fri Apr 3 09:17:19 1998
+++ xosview-1.6.1.a/linux/cpumeter.cc Fri Feb 19 20:55:01 1999
@@ -48,7 +48,7 @@

void CPUMeter::getcputime( void ){
total_ = 0;
- char tmp[256];
+ char tmp[4096];
ifstream stats( STATFILENAME );

if ( !stats ){
@@ -58,7 +58,7 @@

// read until we are at the right line.
for (int i = 0 ; i < _lineNum ; i++)
- stats.getline(tmp, 256);
+ stats.getline(tmp, sizeof(tmp));

stats >>tmp >>cputime_[cpuindex_][0]
>>cputime_[cpuindex_][1]
@@ -86,9 +86,9 @@
}

int line = -1;
- char buf[256];
+ char buf[4096];
while (!stats.eof()){
- stats.getline(buf, 256);
+ stats.getline(buf, sizeof(buf));
if (!stats.eof()){
line++;
if (!strncmp(cpuID, buf, strlen(cpuID)) && buf[strlen(cpuID)] == ' ')
@@ -111,9 +111,9 @@
}

int cpuCount = 0;
- char buf[256];
+ char buf[4096];
while (!stats.eof()){
- stats.getline(buf, 256);
+ stats.getline(buf, sizeof(buf));
if (!stats.eof()){
if (!strncmp(buf, "cpu", 3) && buf[3] != ' ')
cpuCount++;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.141 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site