diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2008-03-08 19:20:13 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2008-03-08 19:20:13 +0000 |
commit | 8574ef8b995918f875877c2b893eac601146a183 (patch) | |
tree | 2d3eb29556bc9b0c42fe3cd119989f47ab516841 /bin/ps/print.c | |
parent | ccc31f18930345203d46b5efd31f56e0498c43b8 (diff) |
Instead of calling donlist() in the format print routines, call it
a single time before we print anything, if needed. Uses a flag to
specify which formats need the kernel info donlist() provides.
OK deraadt@
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r-- | bin/ps/print.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index 05e09a3e72f..578461c87b4 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.43 2007/11/06 10:22:29 chl Exp $ */ +/* $OpenBSD: print.c,v 1.44 2008/03/08 19:20:12 millert Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -static char rcsid[] = "$OpenBSD: print.c,v 1.43 2007/11/06 10:22:29 chl Exp $"; +static char rcsid[] = "$OpenBSD: print.c,v 1.44 2008/03/08 19:20:12 millert Exp $"; #endif #endif /* not lint */ @@ -64,7 +64,7 @@ static char rcsid[] = "$OpenBSD: print.c,v 1.43 2007/11/06 10:22:29 chl Exp $"; #include "ps.h" extern kvm_t *kd; -extern int needenv, needcomm, commandonly; +extern int needenv, needcomm, neednlist, commandonly; static char *cmdpart(char *); @@ -524,12 +524,9 @@ cputime(const struct kinfo_proc2 *kp, VARENT *ve) double getpcpu(const struct kinfo_proc2 *kp) { - static int failure; double d; - if (!nlistread) - failure = donlist(); - if (failure) + if (fscale == 0) return (0.0); #define fxtofl(fixpt) ((double)(fixpt) / fscale) @@ -563,13 +560,10 @@ pcpu(const struct kinfo_proc2 *kp, VARENT *ve) double getpmem(const struct kinfo_proc2 *kp) { - static int failure; double fracmem; int szptudot; - if (!nlistread) - failure = donlist(); - if (failure) + if (mempages == 0) return (0.0); if (kp->p_flag & P_SYSTEM) |