diff options
author | Bartosz Fenski <fenio@debian.org> | 2005-11-04 17:25:27 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:19 +0200 |
commit | 55a3aa9e6a59c1bf0248869d9f08e31ec4057c61 (patch) | |
tree | e45fc349e224501aa3c3dfedbbd6e8f04a8ab62e /ProcessList.c | |
parent | 435b6ae69f41d58f3eefdfcbd63e739387868057 (diff) | |
parent | 2c8c1a156130aa40be7dcaeb3ce2977a03cf50c2 (diff) | |
download | debian_htop-55a3aa9e6a59c1bf0248869d9f08e31ec4057c61.tar.gz debian_htop-55a3aa9e6a59c1bf0248869d9f08e31ec4057c61.tar.bz2 debian_htop-55a3aa9e6a59c1bf0248869d9f08e31ec4057c61.zip |
Imported Debian patch 0.5.4-1debian/0.5.4-1
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ProcessList.c b/ProcessList.c index 93394fb..d5d4ddc 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -1,6 +1,6 @@ /* -htop -(C) 2004 Hisham H. Muhammad +htop - ProcessList.c +(C) 2004,2005 Hisham H. Muhammad Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ @@ -541,14 +541,18 @@ void ProcessList_scan(ProcessList* this) { status = fopen(PROCSTATFILE, "r"); assert(status != NULL); for (int i = 0; i <= this->processorCount; i++) { + char buffer[256]; int cpuid; - int fieldsread; long int ioWait, irq, softIrq, steal; ioWait = irq = softIrq = steal = 0; + // Dependending on your kernel version, + // 5, 7 or 8 of these fields will be set. + // The rest will remain at zero. + fgets(buffer, 255, status); if (i == 0) - fieldsread = fscanf(status, "cpu %ld %ld %ld %ld %ld %ld %ld\n", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal); + sscanf(buffer, "cpu %ld %ld %ld %ld %ld %ld %ld %ld\n", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal); else { - fieldsread = fscanf(status, "cpu%d %ld %ld %ld %ld %ld %ld %ld\n", &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal); + sscanf(buffer, "cpu%d %ld %ld %ld %ld %ld %ld %ld %ld\n", &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal); assert(cpuid == i - 1); } // Fields existing on kernels >= 2.6 |