diff options
author | steve <steve@FreeBSD.org> | 1998-05-25 05:07:18 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1998-05-25 05:07:18 +0000 |
commit | b273678ed229c68dd7202152bcc23af88f3a7a83 (patch) | |
tree | 1c02c16e4380d2bf0c8280688fdb3279fa2e046d /bin/ps/print.c | |
parent | 315fa28d1b5cd78e195a6d5b8725e2a61a09174c (diff) | |
download | FreeBSD-src-b273678ed229c68dd7202152bcc23af88f3a7a83.zip FreeBSD-src-b273678ed229c68dd7202152bcc23af88f3a7a83.tar.gz |
If no value is present for the login name set it to '-'.
Also pretty-up the display of 'ps -Ortprio'.
PR: 4947
Submitted by: Martin Kammerhofer <dada@sbox.tu-graz.ac.at>
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r-- | bin/ps/print.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index 5a6a07f..5d7a0fd 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: print.c,v 1.25 1998/05/15 06:29:16 charnier Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -156,9 +156,10 @@ logname(k, ve) VARENT *ve; { VAR *v; + char *s; v = ve->var; - (void)printf("%-*s", v->width, KI_EPROC(k)->e_login); + (void)printf("%-*s", v->width, (s = KI_EPROC(k)->e_login, *s) ? s : "-"); } void @@ -586,6 +587,38 @@ tsize(k, ve) (void)printf("%*ld", v->width, (long)pgtok(KI_EPROC(k)->e_vm.vm_tsize)); } +void +rtprior(k, ve) + KINFO *k; + VARENT *ve; +{ + VAR *v; + struct rtprio *prtp; + char str[8]; + unsigned prio, type; + + v = ve->var; + prtp = (struct rtprio *) ((char *)KI_PROC(k) + v->off); + prio = prtp->prio; + type = prtp->type; + switch (type) { + case RTP_PRIO_REALTIME: + snprintf(str, sizeof(str), "real:%u", prio); + break; + case RTP_PRIO_NORMAL: + strncpy(str, "normal", sizeof(str)); + break; + case RTP_PRIO_IDLE: + snprintf(str, sizeof(str), "idle:%u", prio); + break; + default: + snprintf(str, sizeof(str), "%u:%u", type, prio); + break; + } + str[sizeof(str) - 1] = '\0'; + (void)printf("%*s", v->width, str); +} + /* * Generic output routines. Print fields from various prototype * structures. |