add support and documentation for the 'e' option, to print out
the process environment.
This commit is contained in:
parent
5089c41368
commit
6ed1026d12
@ -33,7 +33,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)print.c 5.9 (Berkeley) 7/1/91";
|
||||
static char rcsid[] = "$Header: /cvsroot/src/bin/ps/print.c,v 1.3 1993/03/23 00:26:36 cgd Exp $";
|
||||
static char rcsid[] = "$Header: /cvsroot/src/bin/ps/print.c,v 1.4 1993/06/01 01:38:28 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -89,18 +89,28 @@ command(k, v, next)
|
||||
|
||||
if (next == NULL) {
|
||||
/* last field */
|
||||
if (termwidth == UNLIMITED)
|
||||
if (termwidth == UNLIMITED) {
|
||||
if (k->ki_env)
|
||||
(void)printf("%s ", k->ki_env);
|
||||
(void) printf("%s", k->ki_args);
|
||||
else {
|
||||
} else {
|
||||
register int left = termwidth - (totwidth - v->width);
|
||||
register char *cp = k->ki_args;
|
||||
|
||||
if (left < 1) /* already wrapped, just use std width */
|
||||
left = v->width;
|
||||
cp = k->ki_env;
|
||||
if (cp != 0) {
|
||||
while (--left >= 0 && *cp)
|
||||
(void)putchar(*cp++);
|
||||
if (--left >= 0)
|
||||
putchar(' ');
|
||||
}
|
||||
while (--left >= 0 && *cp)
|
||||
(void) putchar(*cp++);
|
||||
}
|
||||
} else
|
||||
/* XXX environment strings? */
|
||||
(void) printf("%-*.*s", v->width, v->width, k->ki_args);
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
.\"
|
||||
.\" @(#)ps.1 6.17 (Berkeley) 6/20/91
|
||||
.\"
|
||||
.\" $Header: /cvsroot/src/bin/ps/ps.1,v 1.3 1993/03/23 00:26:38 cgd Exp $
|
||||
.\" $Header: /cvsroot/src/bin/ps/ps.1,v 1.4 1993/06/01 01:38:30 cgd Exp $
|
||||
.\"
|
||||
.Dd June 20, 1991
|
||||
.Dt PS 1
|
||||
@ -77,6 +77,8 @@ Display information about other users' processes as well as your own.
|
||||
Change the way the cpu percentage is calculated by using a ``raw''
|
||||
cpu calculation that ignores ``resident'' time (this normally has
|
||||
no effect).
|
||||
.It Fl e
|
||||
Display the process environment as well.
|
||||
.It Fl h
|
||||
Repeat the information header as often as necessary to guarantee one
|
||||
header per page of information.
|
||||
|
13
bin/ps/ps.c
13
bin/ps/ps.c
@ -39,7 +39,7 @@ char copyright[] =
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)ps.c 5.43 (Berkeley) 7/1/91";
|
||||
static char rcsid[] = "$Header: /cvsroot/src/bin/ps/ps.c,v 1.4 1993/03/23 00:26:40 cgd Exp $";
|
||||
static char rcsid[] = "$Header: /cvsroot/src/bin/ps/ps.c,v 1.5 1993/06/01 01:38:32 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -73,7 +73,7 @@ int sumrusage; /* -S */
|
||||
int termwidth; /* width of screen (0 == infinity) */
|
||||
int totwidth; /* calculated width of requested variables */
|
||||
|
||||
static int needuser, needcomm;
|
||||
static int needuser, needcomm, needenv;
|
||||
|
||||
enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT;
|
||||
|
||||
@ -124,7 +124,7 @@ main(argc, argv)
|
||||
ttydev = NODEV;
|
||||
memf = nlistf = swapf = NULL;
|
||||
while ((ch = getopt(argc, argv,
|
||||
"aCghjLlM:mN:O:o:p:rSTt:uvW:wx")) != EOF)
|
||||
"aCeghjLlM:mN:O:o:p:rSTt:uvW:wx")) != EOF)
|
||||
switch((char)ch) {
|
||||
case 'a':
|
||||
all = 1;
|
||||
@ -132,6 +132,9 @@ main(argc, argv)
|
||||
case 'C':
|
||||
rawcpu = 1;
|
||||
break;
|
||||
case 'e':
|
||||
needenv = 1;
|
||||
break;
|
||||
case 'g':
|
||||
break; /* no-op */
|
||||
case 'h':
|
||||
@ -352,9 +355,11 @@ saveuser(ki)
|
||||
err("%s", strerror(errno));
|
||||
up = kvm_getu(ki->ki_p);
|
||||
/*
|
||||
* save arguments if needed
|
||||
* save arguments and environment if needed
|
||||
*/
|
||||
ki->ki_args = needcomm ? strdup(kvm_getargs(ki->ki_p, up)) : NULL;
|
||||
ki->ki_env = needenv ? strdup(kvm_getenv(ki->ki_p, up)) : NULL;
|
||||
|
||||
if (up != NULL) {
|
||||
ki->ki_u = usp;
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user