From d1b76f3f6e721c3b27cf2c1eacf9dcfc9870aae6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20E=C3=9Fer?= <se@FreeBSD.org>
Date: Sun, 11 Jun 2006 19:18:39 +0000
Subject: [PATCH] Fix display of idle processes, which had been broken since
 rev. 1.56 of machine.c. The traditional condition was (pctcpu > 0 || SRUN),
 but the negation of the condition logic (from select to skip) made this come
 out as (pctcpu > 0 && SRUN), leading to a very erratic display, except for
 purely CPU bound processes.

This has been discussed in the mail lists some time ago and I have used
top with this patch on my systems for more than a year without problems
(just forgot to commit it earlier, since my systems were all fixed ...).
---
 usr.bin/top/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index fb1823e63fd1..92c82fa9d1bd 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -603,7 +603,8 @@ get_process_info(struct system_info *si, struct process_select *sel,
 			continue;
 
 		if (displaymode == DISP_CPU && !show_idle &&
-		    (pp->ki_pctcpu == 0 || pp->ki_stat != SRUN))
+		    (pp->ki_pctcpu == 0 ||
+		     pp->ki_stat == SSTOP || pp->ki_stat == SIDL))
 			/* skip idle or non-running processes */
 			continue;