aboutsummaryrefslogtreecommitdiffstats
path: root/LoadAverageMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:29 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:29 +0200
commiteaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95 (patch)
tree833f3fae6e3604a439f909c245a6e35f574997d7 /LoadAverageMeter.c
parent283707c5e5bc436b78ea23bf5500cb6b16a01148 (diff)
downloaddebian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.tar.gz
debian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.tar.bz2
debian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.zip
Imported Upstream version 1.0upstream/1.0
Diffstat (limited to 'LoadAverageMeter.c')
-rw-r--r--LoadAverageMeter.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c
index 1109dab..02c8ad5 100644
--- a/LoadAverageMeter.c
+++ b/LoadAverageMeter.c
@@ -1,6 +1,6 @@
/*
htop
-(C) 2004-2010 Hisham H. Muhammad
+(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
@@ -20,12 +20,15 @@ int LoadMeter_attributes[] = { LOAD };
static inline void LoadAverageMeter_scan(double* one, double* five, double* fifteen) {
int activeProcs, totalProcs, lastProc;
+ *one = 0; *five = 0; *fifteen = 0;
FILE *fd = fopen(PROCDIR "/loadavg", "r");
- int total = fscanf(fd, "%lf %lf %lf %d/%d %d", one, five, fifteen,
- &activeProcs, &totalProcs, &lastProc);
- (void) total;
- assert(total == 6);
- fclose(fd);
+ if (fd) {
+ int total = fscanf(fd, "%32lf %32lf %32lf %32d/%32d %32d", one, five, fifteen,
+ &activeProcs, &totalProcs, &lastProc);
+ (void) total;
+ assert(total == 6);
+ fclose(fd);
+ }
}
static void LoadAverageMeter_setValues(Meter* this, char* buffer, int size) {

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