From bc40e61dadc747d61d7b1cc4fd7e6e9864f0155d Mon Sep 17 00:00:00 2001 From: Stathis Kamperis Date: Sun, 4 Jul 2010 09:19:44 +0300 Subject: [PATCH] top: Fix count of process states The count was not in correspondence with our enumeration constants for the process states. For example, an "active" process could be counted as "running". Only tested with i386/UP :) --- usr.bin/top/m_dragonfly.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr.bin/top/m_dragonfly.c b/usr.bin/top/m_dragonfly.c index c23d019ffb..b2ceb08511 100644 --- a/usr.bin/top/m_dragonfly.c +++ b/usr.bin/top/m_dragonfly.c @@ -139,8 +139,7 @@ static struct kinfo_cputime *cp_time, *cp_old; int process_states[6]; char *procstatenames[] = { - "", " starting, ", " running, ", " sleeping, ", " stopped, ", - " zombie, ", + " running, ", " idle, ", " active, ", " stopped, ", " zombie, ", NULL }; @@ -502,7 +501,9 @@ get_process_info(struct system_info *si, struct process_select *sel, if ((show_threads && (LP(pp, pid) == -1)) || (show_system || ((PP(pp, flags) & P_SYSTEM) == 0))) { total_procs++; - process_states[(unsigned char)PP(pp, stat)]++; + if (LP(pp, stat) == LSRUN) + process_states[0]++; + process_states[PP(pp, stat)]++; if ((show_threads && (LP(pp, pid) == -1)) || (show_idle || (LP(pp, pctcpu) != 0) || (LP(pp, stat) == LSRUN)) && -- 2.41.0