aboutsummaryrefslogtreecommitdiff
path: root/bin/ps/print.c
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>1998-05-25 05:07:18 +0000
committerSteve Price <steve@FreeBSD.org>1998-05-25 05:07:18 +0000
commitad863cac06b4376b11d869fb252daa1a83f3a722 (patch)
tree5fe8cda00700ecd9cdf54c99a4e97d8301a6b5cf /bin/ps/print.c
parente172f0e587cba56a647b7c8daa87ef2a58f2fefc (diff)
downloadsrc-ad863cac06b4376b11d869fb252daa1a83f3a722.tar.gz
src-ad863cac06b4376b11d869fb252daa1a83f3a722.zip
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>
Notes
Notes: svn path=/head/; revision=36352
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r--bin/ps/print.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 5a6a07f89a5e..5d7a0fd87f2a 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.