top: fix per status process count reporting
authorJoris Giovannangeli <joris@giovannangeli.fr>
Wed, 19 Nov 2014 11:41:32 +0000 (12:41 +0100)
committerJoris Giovannangeli <joris@giovannangeli.fr>
Wed, 19 Nov 2014 11:41:32 +0000 (12:41 +0100)
usr.bin/top/m_dragonfly.c

index 9bf8fa5..0d24db8 100644 (file)
@@ -491,16 +491,17 @@ get_process_info(struct system_info *si, struct process_select *sel,
                 */
                if ((show_system && (LP(pp, pid) == -1)) ||
                    (show_system || ((PP(pp, flags) & P_SYSTEM) == 0))) {
-                       int pstate = LP(pp, stat);
+                       int lpstate = LP(pp, stat);
+                       int pstate = PP(pp, stat);
 
                        total_procs++;
-                       if (pstate == LSRUN)
+                       if (lpstate == LSRUN)
                                process_states[0]++;
-                       if (pstate >= 0 && pstate < MAXPSTATES)
+                       if (pstate >= 0 && pstate < MAXPSTATES - 1)
                                process_states[pstate]++;
                        if ((show_system && (LP(pp, pid) == -1)) ||
                            (show_idle || (LP(pp, pctcpu) != 0) ||
-                           (pstate == LSRUN)) &&
+                           (lpstate == LSRUN)) &&
                            (!show_uid || PP(pp, ruid) == (uid_t) sel->uid)) {
                                *prefp++ = pp;
                                active_procs++;