summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-09-28 02:42:33 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2014-09-28 02:42:33 +0200
commiteb6a4fc1a4a6e32cd35e76771fe8687b64e9122f (patch)
tree1f46c32b0f0c0fd22777a62ee9dd7913717a2b37 /sys/src
parentc8cf0cee47914699e3e7c10a7b7501af94b53b4e (diff)
devcons: avoid division by zero reading Qsysstat
alexchandel got the kernel to crash with divide error on qemu 2.1.2/macosx at this location. probably caused by perfticks()/tsc being wrong or accounttime() not having been called yet from timer interrupt yet for some reason.
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/9/port/devcons.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/src/9/port/devcons.c b/sys/src/9/port/devcons.c
index 339845a1d..0db1a0e9a 100644
--- a/sys/src/9/port/devcons.c
+++ b/sys/src/9/port/devcons.c
@@ -581,13 +581,14 @@ consread(Chan *c, void *buf, long n, vlong off)
bp += NUMSIZE;
readnum(0, bp, NUMSIZE, mp->load, NUMSIZE);
bp += NUMSIZE;
+ l = mp->perf.period;
+ if(l == 0)
+ l = 1;
readnum(0, bp, NUMSIZE,
- (mp->perf.avg_inidle*100)/mp->perf.period,
- NUMSIZE);
+ (mp->perf.avg_inidle*100)/l, NUMSIZE);
bp += NUMSIZE;
readnum(0, bp, NUMSIZE,
- (mp->perf.avg_inintr*100)/mp->perf.period,
- NUMSIZE);
+ (mp->perf.avg_inintr*100)/l, NUMSIZE);
bp += NUMSIZE;
*bp++ = '\n';
}