mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 10:08:47 +00:00
Go to the next if the current best process is replaced, don't keep comparing it
with itself. Also fix process name comparison.
This commit is contained in:
parent
34a82e7629
commit
6b3b852ebc
35
procname.c
35
procname.c
@ -82,41 +82,48 @@ retry:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_runnable(p) && !is_runnable(bestp))
|
if (is_runnable(p) && !is_runnable(bestp)) {
|
||||||
bestp = p;
|
bestp = p;
|
||||||
else if (!is_runnable(p) && is_runnable(bestp))
|
continue;
|
||||||
|
} else if (!is_runnable(p) && is_runnable(bestp))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!is_stopped(p) && is_stopped(bestp))
|
if (!is_stopped(p) && is_stopped(bestp)) {
|
||||||
bestp = p;
|
bestp = p;
|
||||||
else if (is_stopped(p) && !is_stopped(bestp))
|
continue;
|
||||||
|
} else if (is_stopped(p) && !is_stopped(bestp))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (p->p_estcpu > bestp->p_estcpu)
|
if (p->p_estcpu > bestp->p_estcpu) {
|
||||||
bestp = p;
|
bestp = p;
|
||||||
else if (p->p_estcpu < bestp->p_estcpu)
|
continue;
|
||||||
|
} else if (p->p_estcpu < bestp->p_estcpu)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (p->p_slptime < bestp->p_slptime)
|
if (p->p_slptime < bestp->p_slptime) {
|
||||||
bestp = p;
|
bestp = p;
|
||||||
else if (p->p_slptime > bestp->p_slptime)
|
continue;
|
||||||
|
} else if (p->p_slptime > bestp->p_slptime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (p->p_flag & P_SINTR && !(bestp->p_flag & P_SINTR))
|
if (p->p_flag & P_SINTR && !(bestp->p_flag & P_SINTR)) {
|
||||||
bestp = p;
|
bestp = p;
|
||||||
else if (!(p->p_flag & P_SINTR) && bestp->p_flag & P_SINTR)
|
continue;
|
||||||
|
} else if (!(p->p_flag & P_SINTR) && bestp->p_flag & P_SINTR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (LIST_FIRST(&p->p_children) == NULL &&
|
if (LIST_FIRST(&p->p_children) == NULL &&
|
||||||
LIST_FIRST(&bestp->p_children) != NULL) /* XXX ugh */
|
LIST_FIRST(&bestp->p_children) != NULL) { /* XXX ugh */
|
||||||
bestp = p;
|
bestp = p;
|
||||||
else if (LIST_FIRST(&p->p_children) != NULL &&
|
continue;
|
||||||
|
} else if (LIST_FIRST(&p->p_children) != NULL &&
|
||||||
LIST_FIRST(&bestp->p_children) == NULL)
|
LIST_FIRST(&bestp->p_children) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(p->p_comm, p->p_comm) < 0)
|
if (strcmp(p->p_comm, bestp->p_comm) < 0) {
|
||||||
bestp = p;
|
bestp = p;
|
||||||
else if (strcmp(p->p_comm, p->p_comm) > 0)
|
continue;
|
||||||
|
} else if (strcmp(p->p_comm, bestp->p_comm) > 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (p->p_pid > bestp->p_pid)
|
if (p->p_pid > bestp->p_pid)
|
||||||
|
Loading…
Reference in New Issue
Block a user