bin/59417: ps -o rtprio does not work

Bruce Evans bde at zeta.org.au
Tue Nov 18 14:50:17 PST 2003


The following reply was made to PR bin/59417; it has been noted by GNATS.

From: Bruce Evans <bde at zeta.org.au>
To: Jan Willem Knopper <jwk at stack.nl>
Cc: FreeBSD-gnats-submit at FreeBSD.org, jilles at stack.nl,
	freebsd-gnats-submit at FreeBSD.org
Subject: Re: bin/59417: ps -o rtprio does not work
Date: Wed, 19 Nov 2003 09:39:33 +1100 (EST)

 On Tue, 18 Nov 2003, Jan Willem Knopper wrote:
 
 > >Description:
 > 	'ps -o rtprio' gives junk output: for example '208:208' instead of
 > 	'normal'
 > ...
 > >Fix:
 > 	patch below
 >
 > --- ps-print-rtprio.patch begins here ---
 > --- /usr/src/bin/ps/print.c.orig	Tue Nov 18 15:47:44 2003
 > +++ /usr/src/bin/ps/print.c	Tue Nov 18 15:45:36 2003
 > @@ -655,7 +655,7 @@
 >  	unsigned class, level;
 >
 >  	v = ve->var;
 > -	lpri = (struct priority *) ((char *)k + v->off);
 > +	lpri = (struct priority *) ((char *)k->ki_p + v->off);
 >  	class = lpri->pri_class;
 >  	level = lpri->pri_level;
 >  	switch (class) {
 
 I use the following variant (all the casts are bogus or wrong; not just
 the first one; there are also formatting errors).
 
 %%%
 Index: print.c
 ===================================================================
 RCS file: /home/ncvs/src/bin/ps/print.c,v
 retrieving revision 1.83
 diff -u -2 -r1.83 print.c
 --- print.c	13 Aug 2003 07:35:07 -0000	1.83
 +++ print.c	10 Oct 2003 17:00:05 -0000
 @@ -654,7 +651,7 @@
  	char str[8];
  	unsigned class, level;
 -
 +
  	v = ve->var;
 -	lpri = (struct priority *) ((char *)k + v->off);
 +	lpri = &k->ki_p->ki_pri;
  	class = lpri->pri_class;
  	level = lpri->pri_level;
 %%%
 
 This seems to be the only instance with the same type as the main bug.
 The reason is that v->off is only needed in kvar() and rvar() since
 the relevant struct member cannot be used literally there (only its
 offset is available).  Using v->off elsewhere is bogus and the above
 is the only other place where it used.
 
 Bruce


More information about the freebsd-bugs mailing list