SUSv3 conform on the "comm" and "args" formats, and make correct the "command"

format, since it's BSDlike, and "comm" is actually different.
This commit is contained in:
Juli Mallett 2002-06-06 20:21:47 +00:00
parent b60563db4e
commit 033340171a
4 changed files with 41 additions and 4 deletions

View File

@ -45,6 +45,7 @@ extern int sumrusage, termwidth, totwidth;
extern VARENT *vhead;
__BEGIN_DECLS
void arguments(KINFO *, VARENT *);
void command(KINFO *, VARENT *);
void cputime(KINFO *, VARENT *);
int donlist(void);

View File

@ -85,12 +85,14 @@ static VAR var[] = {
{"acflag", "ACFLG", NULL, 0, kvar, NULL, 3, KOFF(ki_acflag), USHORT,
"x", 0},
{"acflg", "", "acflag", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
{"args", "COMMAND", NULL, COMM|LJUST|USER, arguments, NULL, 16, 0,
CHAR, NULL, 0},
{"blocked", "", "sigmask", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
{"caught", "", "sigcatch", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
{"comm", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16, 0,
{"comm", "COMMAND", NULL, LJUST, ucomm, NULL, MAXCOMLEN, 0, CHAR,
NULL, 0},
{"command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16, 0,
CHAR, NULL, 0},
{"command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16,
0, CHAR, NULL, 0},
{"cpu", "CPU", NULL, 0, kvar, NULL, 3, KOFF(ki_estcpu), UINT, "d",
0},
{"cputime", "", "time", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},

View File

@ -90,6 +90,36 @@ printheader(void)
(void)putchar('\n');
}
void
arguments(KINFO *k, VARENT *ve)
{
VAR *v;
int left;
char *cp, *vis_args;
v = ve->var;
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
errx(1, "malloc failed");
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
if (ve->next == NULL) {
/* last field */
if (termwidth == UNLIMITED) {
(void)printf("%s", vis_args);
} else {
left = termwidth - (totwidth - v->width);
if (left < 1) /* already wrapped, just use std width */
left = v->width;
for (cp = vis_args; --left >= 0 && *cp != '\0';)
(void)putchar(*cp++);
}
} else {
(void)printf("%-*.*s", v->width, v->width, vis_args);
}
free(vis_args);
}
void
command(KINFO *k, VARENT *ve)
{

View File

@ -370,8 +370,12 @@ percentage cpu usage (alias pcpu)
percentage memory usage (alias pmem)
.It acflag
accounting flag (alias acflg)
.It args
command and arguments
.It comm
command and arguments (alias command)
command
.It command
command and arguments
.It cpu
short-term cpu usage factor (for scheduling)
.It flags