diff options
| author | Dima Ruban <dima@FreeBSD.org> | 1998-02-18 22:55:00 +0000 |
|---|---|---|
| committer | Dima Ruban <dima@FreeBSD.org> | 1998-02-18 22:55:00 +0000 |
| commit | d428a4b284e55d9c02f09552a6d0e78e4b85bb52 (patch) | |
| tree | 5455aee51623d98d7c8aa7e4885d68f5e6b48e5c /bin | |
| parent | f287ca6aaa41c2c357a474b6be0c3f06cc779b80 (diff) | |
Notes
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/ps/Makefile | 10 | ||||
| -rw-r--r-- | bin/ps/ps.1 | 6 | ||||
| -rw-r--r-- | bin/ps/ps.c | 38 |
3 files changed, 44 insertions, 10 deletions
diff --git a/bin/ps/Makefile b/bin/ps/Makefile index 31ea6c1374a1..a5bcdbf944a6 100644 --- a/bin/ps/Makefile +++ b/bin/ps/Makefile @@ -1,9 +1,15 @@ # @(#)Makefile 8.1 (Berkeley) 6/2/93 -# $Id: Makefile,v 1.6 1995/10/25 15:07:38 torstenb Exp $ +# $Id: Makefile,v 1.6.2.1 1997/10/16 12:44:17 mckay Exp $ PROG= ps SRCS= fmt.c keyword.c nlist.c print.c ps.c -CFLAGS+=-I${.CURDIR}/../../sys +# +# To support "lazy" ps for non root/wheel users +# add -DLAZY_PS to the cflags. This helps +# keep ps from being an unnecessary load +# on large systems. +# +CFLAGS+=-I${.CURDIR}/../../sys -DLAZY_PS DPADD= ${LIBM} ${LIBKVM} LDADD= -lm -lkvm BINGRP= kmem diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 9e62fa7f0694..7fd1fef07ac2 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 -.\" $Id: ps.1,v 1.11 1996/10/21 07:30:25 peter Exp $ +.\" $Id: ps.1,v 1.11.2.1 1997/08/21 02:54:28 jlemon Exp $ .\" .Dd April 18, 1994 .Dt PS 1 @@ -40,7 +40,7 @@ .Nd process status .Sh SYNOPSIS .Nm \&ps -.Op Fl aCcehjlmrSTuvwx +.Op Fl aCcefhjlmrSTuvwx .Op Fl M Ar core .Op Fl N Ar system .Op Fl O Ar fmt @@ -88,6 +88,8 @@ cpu calculation that ignores ``resident'' time (this normally has no effect). .It Fl e Display the environment as well. +.It Fl f +Work harder to get detailed process information. .It Fl h Repeat the information header as often as necessary to guarantee one header per page of information. diff --git a/bin/ps/ps.c b/bin/ps/ps.c index ba6ec5fe2d6b..581b9fad29c4 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ps.c,v 1.13.2.1 1996/11/11 21:23:15 phk Exp $ + * $Id: ps.c,v 1.13.2.2 1997/06/06 16:09:12 charnier Exp $ */ #ifndef lint @@ -84,6 +84,12 @@ int totwidth; /* calculated width of requested variables */ static int needuser, needcomm, needenv; +#if defined(LAZY_PS) +static int forceuread=0; +#else +static int forceuread=1; +#endif + enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT; static char *fmt __P((char **(*)(kvm_t *, const struct kinfo_proc *, int), @@ -139,7 +145,11 @@ main(argc, argv) ttydev = NODEV; memf = nlistf = swapf = NULL; while ((ch = getopt(argc, argv, +#if defined(LAZY_PS) + "aCcefghjLlM:mN:O:o:p:rSTt:U:uvW:wx")) != EOF) +#else "aCceghjLlM:mN:O:o:p:rSTt:U:uvW:wx")) != EOF) +#endif switch((char)ch) { case 'a': all = 1; @@ -153,6 +163,12 @@ main(argc, argv) case 'e': /* XXX set ufmt */ needenv = 1; break; +#if defined(LAZY_PS) + case 'f': + if (getuid() == 0 || getgid() == 0) + forceuread = 1; + break; +#endif case 'g': break; /* no-op */ case 'h': @@ -393,6 +409,8 @@ fmt(fn, ki, comm, maxlen) return (s); } +#define UREADOK(ki) (forceuread || (KI_PROC(ki)->p_flag & P_INMEM)) + static void saveuser(ki) KINFO *ki; @@ -402,7 +420,7 @@ saveuser(ki) struct user *u_addr = (struct user *)USRSTACK; usp = &ki->ki_u; - if (kvm_uread(kd, KI_PROC(ki), (unsigned long)&u_addr->u_stats, + if (UREADOK(ki) && kvm_uread(kd, KI_PROC(ki), (unsigned long)&u_addr->u_stats, (char *)&pstats, sizeof(pstats)) == sizeof(pstats)) { /* * The u-area might be swapped out, and we can't get @@ -419,15 +437,23 @@ saveuser(ki) /* * save arguments if needed */ - if (needcomm) + if (needcomm && UREADOK(ki)) { ki->ki_args = fmt(kvm_getargv, ki, KI_PROC(ki)->p_comm, MAXCOMLEN); - else + } else if (needcomm) { + ki->ki_args = malloc(strlen(KI_PROC(ki)->p_comm) + 3); + sprintf(ki->ki_args, "(%s)", KI_PROC(ki)->p_comm); + } else { ki->ki_args = NULL; - if (needenv) + } + if (needenv && UREADOK(ki)) { ki->ki_env = fmt(kvm_getenvv, ki, (char *)NULL, 0); - else + } else if (needenv) { + ki->ki_env = malloc(3); + strcpy(ki->ki_env, "()"); + } else { ki->ki_env = NULL; + } } static int |
