diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-02-07 19:16:25 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-02-07 19:16:25 +0000 |
commit | 1d3fba86a3561c93cfbb42137c89fa85c65b0f2b (patch) | |
tree | 4bdd8dc67948b75cdf31b7e67dea46ecdc05de00 /osdep-openbsd.c | |
parent | 69ebc15808d999599cc8d17feb0402d0ebf4ddd4 (diff) |
Make process name guessing pick up SSTOP.
Diffstat (limited to 'osdep-openbsd.c')
-rw-r--r-- | osdep-openbsd.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/osdep-openbsd.c b/osdep-openbsd.c index 4ec03dc8..8cbf6f3d 100644 --- a/osdep-openbsd.c +++ b/osdep-openbsd.c @@ -1,4 +1,4 @@ -/* $Id: osdep-openbsd.c,v 1.7 2009-01-30 21:18:26 nicm Exp $ */ +/* $Id: osdep-openbsd.c,v 1.8 2009-02-07 19:16:25 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,6 +30,11 @@ #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) +#define is_runnable(p) \ + ((p)->p_stat == SRUN || (p)->p_stat == SIDL || (p)->p_stat == SONPROC) +#define is_stopped(p) \ + ((p)->p_stat == SSTOP || (p)->p_stat == SZOMB || (p)->p_stat == SDEAD) + char *get_argv0(int, char *); char *get_proc_argv0(pid_t); @@ -76,17 +81,18 @@ retry: if (bestp == NULL) bestp = p; - if (p->p_stat != SRUN && - p->p_stat != SIDL && - p->p_stat != SONPROC) - continue; + if (is_runnable(p) && !is_runnable(bestp)) + bestp = p; + if (!is_stopped(p) && is_stopped(bestp)) + bestp = p; + if (p->p_estcpu < bestp->p_estcpu) continue; if (p->p_slptime > bestp->p_slptime) continue; if (!(p->p_flag & P_SINTR) && bestp->p_flag & P_SINTR) continue; - if (p->p_pid < bestp->p_pid) + if (LIST_FIRST(&p->p_children) != NULL) continue; bestp = p; } |