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/print.c | |
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/print.c')
-rw-r--r-- | bin/ps/print.c | 30 |
1 files changed, 30 insertions, 0 deletions
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; |