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
This commit is contained in:
Tim J. Robbins 2003-04-12 10:39:56 +00:00
parent ad3648813c
commit e2c9ac698c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113395
3 changed files with 6 additions and 3 deletions

View File

@ -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},

View File

@ -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);

View File

@ -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 *);