Even better.

This commit is contained in:
Nicholas Marriott 2009-02-07 19:24:50 +00:00
parent 1d3fba86a3
commit f53bcc8798
2 changed files with 12 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $Id: osdep-freebsd.c,v 1.5 2009-02-07 19:16:25 nicm Exp $ */ /* $Id: osdep-freebsd.c,v 1.6 2009-02-07 19:24:50 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -39,7 +39,7 @@ char *get_proc_argv0(pid_t);
#define is_runnable(p) \ #define is_runnable(p) \
((p)->ki_stat == SRUN || (p)->ki_stat == SIDL) ((p)->ki_stat == SRUN || (p)->ki_stat == SIDL)
#define is_stopped(p) \ #define is_stopped(p) \
((p)->ki_stat == SSTOP || (p)->ki_stat == SZOMB || (p)->ki_stat == SDEAD) ((p)->ki_stat == SSTOP || (p)->ki_stat == SZOMB)
char * char *
get_argv0(__attribute__ ((unused)) int fd, char *tty) get_argv0(__attribute__ ((unused)) int fd, char *tty)

View File

@ -1,4 +1,4 @@
/* $Id: osdep-openbsd.c,v 1.8 2009-02-07 19:16:25 nicm Exp $ */ /* $Id: osdep-openbsd.c,v 1.9 2009-02-07 19:24:50 nicm Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -85,16 +85,15 @@ retry:
bestp = p; bestp = p;
if (!is_stopped(p) && is_stopped(bestp)) if (!is_stopped(p) && is_stopped(bestp))
bestp = p; bestp = p;
if (p->p_estcpu > bestp->p_estcpu)
if (p->p_estcpu < bestp->p_estcpu) bestp = p;
continue; if (p->p_slptime < bestp->p_slptime)
if (p->p_slptime > bestp->p_slptime) bestp = p;
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;
continue; if (LIST_FIRST(&p->p_children) == NULL &&
if (LIST_FIRST(&p->p_children) != NULL) LIST_FIRST(&bestp->p_children) != NULL)
continue; bestp = p;
bestp = p;
} }
if (bestp != NULL) { if (bestp != NULL) {
procname = get_proc_argv0(bestp->p_pid); procname = get_proc_argv0(bestp->p_pid);