diff options
author | trasz <trasz@FreeBSD.org> | 2011-03-05 14:41:49 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2011-03-05 14:41:49 +0000 |
commit | 1618438630910db9238a8bf1808fd696eba7c86f (patch) | |
tree | 24572b457547ac678a031b594014ab4d5aa60b4a /bin | |
parent | 1a2c2ccf00d839e96bbb9cb391027b14ec4e0d05 (diff) | |
download | FreeBSD-src-1618438630910db9238a8bf1808fd696eba7c86f.zip FreeBSD-src-1618438630910db9238a8bf1808fd696eba7c86f.tar.gz |
Export login class information via kinfo and make it possible to view
it using "ps -o class".
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ps/extern.h | 1 | ||||
-rw-r--r-- | bin/ps/keyword.c | 2 | ||||
-rw-r--r-- | bin/ps/print.c | 20 | ||||
-rw-r--r-- | bin/ps/ps.1 | 6 |
4 files changed, 28 insertions, 1 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h index b177b47..faeeb19 100644 --- a/bin/ps/extern.h +++ b/bin/ps/extern.h @@ -55,6 +55,7 @@ const char *fmt_argv(char **, char *, size_t); double getpcpu(const KINFO *); void kvar(KINFO *, VARENT *); void label(KINFO *, VARENT *); +void loginclass(KINFO *, VARENT *); void logname(KINFO *, VARENT *); void longtname(KINFO *, VARENT *); void lstarted(KINFO *, VARENT *); diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index 561b087..3bcc23b 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -79,6 +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}, {"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, diff --git a/bin/ps/print.c b/bin/ps/print.c index 5aa27c0..46b979b 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -862,6 +862,26 @@ out: return; } +void +loginclass(KINFO *k, VARENT *ve) +{ + VAR *v; + char *s; + + v = ve->var; + /* + * Don't display login class for system processes; + * login classes are used for resource limits, + * and limits don't apply to system processes. + */ + if (k->ki_p->ki_flag & P_SYSTEM) { + (void)printf("%-*s", v->width, " -"); + return; + } + s = k->ki_p->ki_loginclass; + (void)printf("%-*s", v->width, *s ? s : "-"); +} + int s_comm(KINFO *k) { diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 9dd7a47..5ae7c54 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -29,7 +29,7 @@ .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd July 24, 2010 +.Dd March 5, 2011 .Dt PS 1 .Os .Sh NAME @@ -280,6 +280,8 @@ be very young) it is possible for the sum of all fields to exceed 100%. .It Cm %mem The percentage of real memory used by this process. +.It Cm class +Login class associated with the process. .It Cm flags The flags associated with the process as in the include file @@ -475,6 +477,8 @@ accounting flag (alias .Cm acflg ) .It Cm args command and arguments +.It Cm class +login class .It Cm comm command .It Cm command |