Hi, slstatus crashes (not always but often) after (suspend and) resume on OpenBSD amd64.
The problem is in the OpenBSD section of components/cpu.c when `a` is identical to `b` which leads to a division by zero. E.g., in one case I had a: CP_USER 28357, CP_NICE 0, CP_SYS 10376, CP_INTR 1681, CP_IDLE 1112152 b: CP_USER 28357, CP_NICE 0, CP_SYS 10376, CP_INTR 1681, CP_IDLE 1112152 So this patch checks this condition and returns. Feel free to modify this patch (e.g., a variable could be introduced to avoid the redundant sum (in the check and in the division) if you prefer this). Best regards, Ingo
>From 8e2ec259cbc053647d982cc81039daa8c3832cbe Mon Sep 17 00:00:00 2001 From: Ingo Feinerer <[email protected]> Date: Wed, 13 Feb 2019 22:07:34 +0100 Subject: [PATCH] cpu_perc: Check for division by zero --- components/cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/cpu.c b/components/cpu.c index d9bd018..47a10c5 100644 --- a/components/cpu.c +++ b/components/cpu.c @@ -92,6 +92,11 @@ return NULL; } + if (a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR] + a[CP_IDLE] == + b[CP_USER] + b[CP_NICE] + b[CP_SYS] + b[CP_INTR] + b[CP_IDLE]) { + return NULL; + } + return bprintf("%d", 100 * ((a[CP_USER] + a[CP_NICE] + a[CP_SYS] + a[CP_INTR]) - -- 2.20.1
