aboutsummaryrefslogtreecommitdiffstats
path: root/ProcessList.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:18 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:18 +0200
commit2c8c1a156130aa40be7dcaeb3ce2977a03cf50c2 (patch)
treeafaa05858260763c1d25fa092f3905cf51ffd7b2 /ProcessList.c
parent031c3bb95f3d0a74d985286068baa6dd4d29d83f (diff)
downloaddebian_htop-2c8c1a156130aa40be7dcaeb3ce2977a03cf50c2.tar.gz
debian_htop-2c8c1a156130aa40be7dcaeb3ce2977a03cf50c2.tar.bz2
debian_htop-2c8c1a156130aa40be7dcaeb3ce2977a03cf50c2.zip
Imported Upstream version 0.5.4upstream/0.5.4
Diffstat (limited to 'ProcessList.c')
-rw-r--r--ProcessList.c14
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

© 2014-2024 Faster IT GmbH | imprint | privacy policy