aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2003-04-12 10:39:56 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2003-04-12 10:39:56 +0000
commite2c9ac698cf2d868bc070ac33d094e2baa3f8a60 (patch)
tree49b3b72affbfe7bcc0858f40a21d521e750d79e1 /bin
parentad3648813cfe3e9eb31e06d050abee1e7ae0b575 (diff)
downloadsrc-e2c9ac698cf2d868bc070ac33d094e2baa3f8a60.tar.gz
src-e2c9ac698cf2d868bc070ac33d094e2baa3f8a60.zip
Display residency and sleep times (re and sl fields) larger than 127 as 127.
This is what the manual page says ps should do, and what OpenBSD and NetBSD do. Based on a patch from Ken Stailey. PR: 27433, 46232
Notes
Notes: svn path=/head/; revision=113395
Diffstat (limited to 'bin')
-rw-r--r--bin/ps/keyword.c4
-rw-r--r--bin/ps/print.c4
-rw-r--r--bin/ps/ps.h1
3 files changed, 6 insertions, 3 deletions
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index 545694539ea8..d893d0fa67c1 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -143,7 +143,7 @@ static VAR var[] = {
{"ppid", "PPID", NULL, 0, kvar, NULL, PIDLEN, KOFF(ki_ppid), UINT,
PIDFMT, 0},
{"pri", "PRI", NULL, 0, pri, NULL, 3, 0, CHAR, NULL, 0},
- {"re", "RE", NULL, 0, kvar, NULL, 3, KOFF(ki_swtime), UINT, "d",
+ {"re", "RE", NULL, INF127, kvar, NULL, 3, KOFF(ki_swtime), UINT, "d",
0},
{"rgid", "RGID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_rgid),
UINT, UIDFMT, 0},
@@ -166,7 +166,7 @@ static VAR var[] = {
UINT, "x", 0},
{"sigmask", "BLOCKED", NULL, 0, kvar, NULL, 8, KOFF(ki_sigmask),
UINT, "x", 0},
- {"sl", "SL", NULL, 0, kvar, NULL, 3, KOFF(ki_slptime), UINT, "d",
+ {"sl", "SL", NULL, INF127, kvar, NULL, 3, KOFF(ki_slptime), UINT, "d",
0},
{"start", "STARTED", NULL, LJUST|USER, started, NULL, 7, 0, CHAR, NULL,
0},
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 69d33bac6a16..69fcba9a33ad 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -694,6 +694,8 @@ printval(void *bp, VAR *v)
*cp++ = '*';
while ((*cp++ = *fcp++));
+#define CHKINF127(n) (((n) > 127) && (v->flag & INF127) ? 127 : (n))
+
switch (v->type) {
case CHAR:
(void)printf(ofmt, v->width, *(char *)bp);
@@ -711,7 +713,7 @@ printval(void *bp, VAR *v)
(void)printf(ofmt, v->width, *(int *)bp);
break;
case UINT:
- (void)printf(ofmt, v->width, *(u_int *)bp);
+ (void)printf(ofmt, v->width, CHKINF127(*(u_int *)bp));
break;
case LONG:
(void)printf(ofmt, v->width, *(long *)bp);
diff --git a/bin/ps/ps.h b/bin/ps/ps.h
index 2fd10de7c0bb..6d84697eb75e 100644
--- a/bin/ps/ps.h
+++ b/bin/ps/ps.h
@@ -59,6 +59,7 @@ typedef struct var {
#define LJUST 0x02 /* left adjust on output (trailing blanks) */
#define USER 0x04 /* needs user structure */
#define DSIZ 0x08 /* field size is dynamic*/
+#define INF127 0x10 /* values >127 displayed as 127 */
u_int flag;
/* output routine */
void (*oproc)(struct kinfo *, struct varent *);