top: Fix count of process states
authorStathis Kamperis <beket@dragonflybsd.org>
Sun, 4 Jul 2010 06:19:44 +0000 (09:19 +0300)
committerStathis Kamperis <beket@dragonflybsd.org>
Sun, 4 Jul 2010 21:47:40 +0000 (00:47 +0300)
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

index c23d019..b2ceb08 100644 (file)
@@ -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)) &&