diff options
author | trasz <trasz@FreeBSD.org> | 2011-03-24 17:20:24 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2011-03-24 17:20:24 +0000 |
commit | 7a8bd43974c3b65965d0a1661898bf7a3f1ff052 (patch) | |
tree | 980af12c457ea8c63e75a33eb60c2b8270f7a7a4 /bin | |
parent | 6e5f09a2229c3dafda3b8dd3581af91e48db5919 (diff) | |
download | FreeBSD-src-7a8bd43974c3b65965d0a1661898bf7a3f1ff052.zip FreeBSD-src-7a8bd43974c3b65965d0a1661898bf7a3f1ff052.tar.gz |
Make "LOGIN" and "CLASS" columns width scale properly instead of wasting space.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ps/extern.h | 2 | ||||
-rw-r--r-- | bin/ps/keyword.c | 8 | ||||
-rw-r--r-- | bin/ps/print.c | 29 |
3 files changed, 34 insertions, 5 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h index eb1ede6..6103473 100644 --- a/bin/ps/extern.h +++ b/bin/ps/extern.h @@ -75,6 +75,8 @@ void runame(KINFO *, VARENT *); void rvar(KINFO *, VARENT *); int s_comm(KINFO *); int s_label(KINFO *); +int s_loginclass(KINFO *); +int s_logname(KINFO *); int s_rgroupname(KINFO *); int s_runame(KINFO *); int s_uname(KINFO *); diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index 09eb756..9be2f9c 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -79,8 +79,8 @@ static VAR var[] = { CHAR, NULL, 0}, {"blocked", "", "sigmask", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, {"caught", "", "sigcatch", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, - {"class", "CLASS", NULL, LJUST, loginclass, NULL, MAXLOGNAME-1, 0, - CHAR, NULL, 0}, + {"class", "CLASS", NULL, LJUST|DSIZ, loginclass, s_loginclass, + MAXLOGNAME-1, 0, CHAR, NULL, 0}, {"comm", "COMMAND", NULL, LJUST|DSIZ, ucomm, s_comm, COMMLEN + OCOMMLEN + 1, 0, CHAR, NULL, 0}, {"command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16, 0, @@ -108,8 +108,8 @@ static VAR var[] = { {"lim", "LIM", NULL, 0, maxrss, NULL, 5, 0, CHAR, NULL, 0}, {"lockname", "LOCK", NULL, LJUST, lockname, NULL, 6, 0, CHAR, NULL, 0}, - {"login", "LOGIN", NULL, LJUST, logname, NULL, MAXLOGNAME-1, 0, CHAR, - NULL, 0}, + {"login", "LOGIN", NULL, LJUST|DSIZ, logname, s_logname, MAXLOGNAME-1, + 0, CHAR, NULL, 0}, {"logname", "", "login", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, {"lstart", "STARTED", NULL, LJUST|USER, lstarted, NULL, 28, 0, CHAR, NULL, 0}, diff --git a/bin/ps/print.c b/bin/ps/print.c index 253793a..0c97030 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -908,7 +908,7 @@ loginclass(KINFO *k, VARENT *ve) * and limits don't apply to system processes. */ if (k->ki_p->ki_flag & P_SYSTEM) { - (void)printf("%-*s", v->width, " -"); + (void)printf("%-*s", v->width, "-"); return; } s = k->ki_p->ki_loginclass; @@ -948,3 +948,30 @@ s_label(KINFO *k) mac_free(proclabel); return (size); } + +int +s_loginclass(KINFO *k) +{ + char *s; + + if (k->ki_p->ki_flag & P_SYSTEM) + return (1); + + s = k->ki_p->ki_loginclass; + if (s == NULL) + return (1); + + return (strlen(s)); +} + +int +s_logname(KINFO *k) +{ + char *s; + + s = k->ki_p->ki_login; + if (s == NULL) + return (1); + + return (strlen(s)); +} |