aboutsummaryrefslogtreecommitdiff
path: root/bin/ps
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2011-03-24 17:20:24 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2011-03-24 17:20:24 +0000
commit3bf92decd3e03e997e35e4b4d045fd35cb641e53 (patch)
tree980af12c457ea8c63e75a33eb60c2b8270f7a7a4 /bin/ps
parentc6b2aa689a832a977f4e64cae3cbe04710311b93 (diff)
downloadsrc-3bf92decd3e03e997e35e4b4d045fd35cb641e53.tar.gz
src-3bf92decd3e03e997e35e4b4d045fd35cb641e53.zip
Make "LOGIN" and "CLASS" columns width scale properly instead of wasting space.
Notes
Notes: svn path=/head/; revision=219967
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/extern.h2
-rw-r--r--bin/ps/keyword.c8
-rw-r--r--bin/ps/print.c29
3 files changed, 34 insertions, 5 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index eb1ede6e46e3..610347346e7e 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 09eb75663f7e..9be2f9c8d542 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 253793acad1b..0c970304c4b3 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));
+}