diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-06-06 20:21:47 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-06-06 20:21:47 +0000 |
commit | 562b4c02507bd0c452d9229307892f9c41a9c555 (patch) | |
tree | a33b2f0e02aa1848f1243fb6999d497353ba27cd /bin/ps | |
parent | e5b172f462d498835247f250a9e0a4b975c7681d (diff) | |
download | FreeBSD-src-562b4c02507bd0c452d9229307892f9c41a9c555.zip FreeBSD-src-562b4c02507bd0c452d9229307892f9c41a9c555.tar.gz |
SUSv3 conform on the "comm" and "args" formats, and make correct the "command"
format, since it's BSDlike, and "comm" is actually different.
Diffstat (limited to 'bin/ps')
-rw-r--r-- | bin/ps/extern.h | 1 | ||||
-rw-r--r-- | bin/ps/keyword.c | 8 | ||||
-rw-r--r-- | bin/ps/print.c | 30 | ||||
-rw-r--r-- | bin/ps/ps.1 | 6 |
4 files changed, 41 insertions, 4 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h index ecb86f0..2ea5724 100644 --- a/bin/ps/extern.h +++ b/bin/ps/extern.h @@ -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); diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index 729a7c4..b54cb43 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -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}, diff --git a/bin/ps/print.c b/bin/ps/print.c index f885770..e3c3a3e 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -91,6 +91,36 @@ printheader(void) } 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) { VAR *v; diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 43fbdef..80f541d 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -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 |