From dima@unixfreak.org  Sat Mar 24 16:06:30 2001
Return-Path: <dima@unixfreak.org>
Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138])
	by hub.freebsd.org (Postfix) with ESMTP id A8E8F37B719
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 24 Mar 2001 16:06:29 -0800 (PST)
	(envelope-from dima@unixfreak.org)
Received: from spike.unixfreak.org (spike [63.198.170.139])
	by bazooka.unixfreak.org (Postfix) with ESMTP id 738303E25
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 24 Mar 2001 16:06:29 -0800 (PST)
Received: (from dima@localhost)
	by spike.unixfreak.org (8.11.3/8.11.1) id f2P06SE13697;
	Sat, 24 Mar 2001 16:06:28 -0800 (PST)
	(envelope-from dima)
Message-Id: <200103250006.f2P06SE13697@spike.unixfreak.org>
Date: Sat, 24 Mar 2001 16:06:28 -0800 (PST)
From: dd@freebsd.org
Reply-To: dd@freebsd.org
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] Minor ps(1) fixes
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         26057
>Category:       bin
>Synopsis:       [PATCH] Minor ps(1) fixes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 24 16:10:01 PST 2001
>Closed-Date:    Fri Apr 6 20:19:09 PDT 2001
>Last-Modified:  Sat Apr  7 01:20:01 PDT 2001
>Originator:     Dima Dorfman
>Release:        FreeBSD 5.0-20010310-CURRENT i386
>Organization:
Private
>Environment:
System: FreeBSD spike.unixfreak.org 5.0-20010310-CURRENT FreeBSD 5.0-20010310-CURRENT #22: Sat Mar 24 13:28:08 PST 2001 dima@spike.unixfreak.org:/c/home/dima/w/f/src/sys/compile/SPIKE i386

>Description:

When the kinfo_proc structure was introduced, the ps(1) manual page
was not updated.  Thus, it still talks about keywords that don't
exist.  Also, one line in ps.c was forgotten.  The latter results in
an annoying warning when using ps(1) with the -j flag (see
how-to-repeat).

>How-To-Repeat:

        dd@ref5% ps -j
        ps: sess: keyword not found
        [ normal ps(1) output follows ]

>Fix:

The following patch fixes the warning and updates the man page.  I'm
only a doc committer, so someone else needs to commit the src/ part.

Index: ps.1
===================================================================
RCS file: /st/src/FreeBSD/src/bin/ps/ps.1,v
retrieving revision 1.30
diff -u -r1.30 ps.1
--- ps.1	2001/02/01 16:24:50	1.30
+++ ps.1	2001/03/20 03:34:55
@@ -99,7 +99,7 @@
 header per page of information.
 .It Fl j
 Print information associated with the following keywords:
-user, pid, ppid, pgid, sess, jobc, state, tt, time and command.
+user, pid, ppid, pgid, jobc, state, tt, time and command.
 .It Fl L
 List the set of available keywords.
 .It Fl l
@@ -367,8 +367,6 @@
 job control count
 .It ktrace
 tracing flags
-.It ktracep
-tracing vnode
 .It lim
 memoryuse limit
 .It logname
@@ -400,8 +398,6 @@
 wait channel (as an address)
 .It oublk
 total blocks written (alias oublock)
-.It p_ru
-resource usage (valid only for zombie)
 .It paddr
 swap address
 .It pagein
@@ -427,8 +423,6 @@
 reverse link on run queue, or 0
 .It rss
 resident set size
-.It rsz
-resident set size + (text size / text use count) (alias rssize)
 .It rtprio
 realtime priority (101 = not a realtime process)
 .It ruid
@@ -436,8 +430,6 @@
 .Tn ID
 .It ruser
 user name (from ruid)
-.It sess
-session pointer
 .It sig
 pending signals (alias pending)
 .It sigcatch
Index: ps.c
===================================================================
RCS file: /st/src/FreeBSD/src/bin/ps/ps.c,v
retrieving revision 1.36
diff -u -r1.36 ps.c
--- ps.c	2001/03/03 01:46:58	1.36
+++ ps.c	2001/03/20 03:34:55
@@ -104,7 +104,7 @@
 static uid_t	*getuids(const char *, int *);
 
 char dfmt[] = "pid tt state time command";
-char jfmt[] = "user pid ppid pgid sess jobc state tt time command";
+char jfmt[] = "user pid ppid pgid jobc state tt time command";
 char lfmt[] = "uid pid ppid cpu pri nice vsz rss wchan state tt time command";
 char   o1[] = "pid";
 char   o2[] = "tt state time command";


>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: dd@FreeBSD.ORG
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/26057: [PATCH] Minor ps(1) fixes
Date: Sun, 25 Mar 2001 14:40:31 +1000 (EST)

 On Sat, 24 Mar 2001 dd@FreeBSD.ORG wrote:
 
 > >Description:
 > 
 > When the kinfo_proc structure was introduced, the ps(1) manual page
 > was not updated.  Thus, it still talks about keywords that don't
 > exist.  Also, one line in ps.c was forgotten.  The latter results in
 > an annoying warning when using ps(1) with the -j flag (see
 > how-to-repeat).
 
 Some of the bugs are in kinfo_proc, not in ps.
 
 > Index: ps.1
 > ===================================================================
 > RCS file: /st/src/FreeBSD/src/bin/ps/ps.1,v
 > retrieving revision 1.30
 > diff -u -r1.30 ps.1
 > --- ps.1	2001/02/01 16:24:50	1.30
 > +++ ps.1	2001/03/20 03:34:55
 > @@ -99,7 +99,7 @@
 >  header per page of information.
 >  .It Fl j
 >  Print information associated with the following keywords:
 > -user, pid, ppid, pgid, sess, jobc, state, tt, time and command.
 > +user, pid, ppid, pgid, jobc, state, tt, time and command.
 
 I think the seesion pointer can be used to distinguish sessions.
 pstat(8) still prints it (pstat gets it in a different way).
 
 >...
 > -.It ktracep
 > -tracing vnode
 >...
 > -.It p_ru
 > -resource usage (valid only for zombie)
 
 Other pointers may be useful for groping in kmem or in panic dumps, but
 gdb is better for that.
 
 I hacked my ps to show the cputime() resource usage for zombies in all
 cases.  It's not very useful to print it as 0.
 
 > -.It rsz
 > -resident set size + (text size / text use count) (alias rssize)
 
 Hopefully no one uses this any more.
 
 Bruce
 

From: Dima Dorfman <dima@unixfreak.org>
To: Bruce Evans <bde@zeta.org.au>
Cc: dd@FreeBSD.ORG, FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/26057: [PATCH] Minor ps(1) fixes 
Date: Sat, 24 Mar 2001 22:42:08 -0800

 Bruce Evans <bde@zeta.org.au> writes:
 > On Sat, 24 Mar 2001 dd@FreeBSD.ORG wrote:
 > > Index: ps.1
 > > ===================================================================
 > > RCS file: /st/src/FreeBSD/src/bin/ps/ps.1,v
 > > retrieving revision 1.30
 > > diff -u -r1.30 ps.1
 > > --- ps.1	2001/02/01 16:24:50	1.30
 > > +++ ps.1	2001/03/20 03:34:55
 > > @@ -99,7 +99,7 @@
 > >  header per page of information.
 > >  .It Fl j
 > >  Print information associated with the following keywords:
 > > -user, pid, ppid, pgid, sess, jobc, state, tt, time and command.
 > > +user, pid, ppid, pgid, jobc, state, tt, time and command.
 > 
 > I think the seesion pointer can be used to distinguish sessions.
 > pstat(8) still prints it (pstat gets it in a different way).
 
 This is trivial to fix.  See the patch below.
 
 > 
 > >...
 > > -.It ktracep
 > > -tracing vnode
 > >...
 > > -.It p_ru
 > > -resource usage (valid only for zombie)
 > 
 > Other pointers may be useful for groping in kmem or in panic dumps, but
 > gdb is better for that.
 > 
 > I hacked my ps to show the cputime() resource usage for zombies in all
 > cases.  It's not very useful to print it as 0.
 
 struct rusage is exported in kinfo_proc as ki_rusage, but I don't
 think ps knows about it.  I guess this is also trivial to fix, but I
 haven't tried.  I'll supply a patch for this if you want, too.
 
 The patch below adds the 'sess' option back to ps.  Mckusick
 explicitly said he was removing it in his kinfo_proc commit, but
 didn't specify a reason.
 
 Regards
 
 					Dima Dorfman
 					dima@unixfreak.org
 
 Index: bin/ps/keyword.c
 ===================================================================
 RCS file: /st/src/FreeBSD/src/bin/ps/keyword.c,v
 retrieving revision 1.29
 diff -u -r1.29 keyword.c
 --- bin/ps/keyword.c	2001/02/14 18:54:34	1.29
 +++ bin/ps/keyword.c	2001/03/25 06:35:03
 @@ -148,6 +148,7 @@
  	{"ruid", "RUID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_ruid),
  		UINT, UIDFMT},
  	{"ruser", "RUSER", NULL, LJUST|DSIZ, runame, s_runame, USERLEN},
 +	{"sess", "SESS", NULL, 0, kvar, NULL, 6, KOFF(ki_sess), KPTR, "lx"},
  	{"sig", "PENDING", NULL, 0, kvar, NULL, 8, KOFF(ki_siglist), INT, "x"},
  	{"sigcatch", "CAUGHT",
  		NULL, 0, kvar, NULL, 8, KOFF(ki_sigcatch), UINT, "x"},
 Index: lib/libkvm/kvm_proc.c
 ===================================================================
 RCS file: /st/src/FreeBSD/src/lib/libkvm/kvm_proc.c,v
 retrieving revision 1.32
 diff -u -r1.32 kvm_proc.c
 --- lib/libkvm/kvm_proc.c	2001/02/12 00:21:09	1.32
 +++ lib/libkvm/kvm_proc.c	2001/03/25 06:35:03
 @@ -320,6 +320,7 @@
  		kp->ki_rqindex = proc.p_rqindex;
  		kp->ki_oncpu = proc.p_oncpu;
  		kp->ki_lastcpu = proc.p_lastcpu;
 +		kp->ki_sess = proc.p_session;
  		bcopy(&kinfo_proc, bp, sizeof(kinfo_proc));
  		++bp;
  		++cnt;
 Index: sys/kern/kern_proc.c
 ===================================================================
 RCS file: /st/src/FreeBSD/src/sys/kern/kern_proc.c,v
 retrieving revision 1.89
 diff -u -r1.89 kern_proc.c
 --- sys/kern/kern_proc.c	2001/03/07 06:52:12	1.89
 +++ sys/kern/kern_proc.c	2001/03/25 06:35:03
 @@ -509,6 +509,7 @@
  	kp->ki_lock = p->p_lock;
  	if (p->p_pptr)
  		kp->ki_ppid = p->p_pptr->p_pid;
 +	kp->ki_sess = p->p_session;
  	PROC_UNLOCK(p);
  } 
  
 Index: sys/sys/user.h
 ===================================================================
 RCS file: /st/src/FreeBSD/src/sys/sys/user.h,v
 retrieving revision 1.35
 diff -u -r1.35 user.h
 --- sys/sys/user.h	2001/03/09 11:34:29	1.35
 +++ sys/sys/user.h	2001/03/25 06:35:03
 @@ -149,7 +149,8 @@
  	struct	rusage ki_rusage;	/* process rusage statistics */
  	long	ki_sflag;		/* PS_* flags */
  	struct	priority ki_pri;	/* process priority */
 -	long	ki_spare[25];		/* spare constants */
 +	struct	session *ki_sess;	/* session pointer */
 +	long	ki_spare[24];		/* spare constants */
  };
  void fill_kinfo_proc __P((struct proc *, struct kinfo_proc *));
  
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Wed Mar 28 10:27:20 PST 2001 
State-Changed-Why:  
I think the reason for the 'w' option in the first place is 
to disable the default window-width setting. 

As Wollman notes, breaking a very common case would hurt POLA. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26057 
State-Changed-From-To: closed->open 
State-Changed-By: phk 
State-Changed-When: Wed Mar 28 11:07:08 PST 2001 
State-Changed-Why:  
Dang, wrong PR.  Ignore last entry. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26057 

From: Dima Dorfman <dima@unixfreak.org>
To: phk@FreeBSD.org
Cc: dd@freebsd.org, freebsd-gnats-submit@freebsd.org
Subject: Re: bin/26057: [PATCH] Minor ps(1) fixes 
Date: Wed, 28 Mar 2001 11:03:46 -0800

 <phk@FreeBSD.org> writes:
 > Synopsis: [PATCH] Minor ps(1) fixes
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: phk
 > State-Changed-When: Wed Mar 28 10:27:20 PST 2001
 > State-Changed-Why: 
 > I think the reason for the 'w' option in the first place is
 > to disable the default window-width setting.
 > 
 > As Wollman notes, breaking a very common case would hurt POLA.
 
 Um, I think you closed the wrong PR.  This one does not talk about the
 'w' option.  PR 25855 does.  This one fixes this:
 
 	dd@ref5% ps j
 	ps: sess: keyword not found
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 	[ normal ps output ]
 
 and some stuff in a man page.  Also note that Wollman never said
 anything about this PR.
 
 Please re-open (and/or commit :-) it.
 
 Regards
 
 					Dima Dorfman
 					dima@unixfreak.org
 

From: Poul-Henning Kamp <phk@critter.freebsd.dk>
To: Dima Dorfman <dima@unixfreak.org>
Cc: dd@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/26057: [PATCH] Minor ps(1) fixes 
Date: Wed, 28 Mar 2001 21:08:31 +0200

 Thanks for noticing my cut&paste-o :-!
 
 In message <20010328190346.F3D1C3E09@bazooka.unixfreak.org>, Dima Dorfman write
 s:
 ><phk@FreeBSD.org> writes:
 >> Synopsis: [PATCH] Minor ps(1) fixes
 >> 
 >> State-Changed-From-To: open->closed
 >> State-Changed-By: phk
 >> State-Changed-When: Wed Mar 28 10:27:20 PST 2001
 >> State-Changed-Why: 
 >> I think the reason for the 'w' option in the first place is
 >> to disable the default window-width setting.
 >> 
 >> As Wollman notes, breaking a very common case would hurt POLA.
 >
 >Um, I think you closed the wrong PR.  This one does not talk about the
 >'w' option.  PR 25855 does.  This one fixes this:
 >
 >	dd@ref5% ps j
 >	ps: sess: keyword not found
 >       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 >	[ normal ps output ]
 >
 >and some stuff in a man page.  Also note that Wollman never said
 >anything about this PR.
 >
 >Please re-open (and/or commit :-) it.
 >
 >Regards
 >
 >					Dima Dorfman
 >					dima@unixfreak.org
 >
 >
 
 --
 Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
 phk@FreeBSD.ORG         | TCP/IP since RFC 956
 FreeBSD committer       | BSD since 4.3-tahoe    
 Never attribute to malice what can adequately be explained by incompetence.
State-Changed-From-To: open->closed 
State-Changed-By: dd 
State-Changed-When: Fri Apr 6 20:19:09 PDT 2001 
State-Changed-Why:  
ps.c part committed by brian (1.37 of bin/ps/ps.c).  I'll update the 
man page later today. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26057 

From: Bruce Evans <bde@zeta.org.au>
To: dd@FreeBSD.ORG
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/26057: [PATCH] Minor ps(1) fixes
Date: Sat, 7 Apr 2001 18:13:38 +1000 (EST)

 On Fri, 6 Apr 2001 dd@FreeBSD.ORG wrote:
 
 > Synopsis: [PATCH] Minor ps(1) fixes
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: dd
 > State-Changed-When: Fri Apr 6 20:19:09 PDT 2001
 > State-Changed-Why: 
 > ps.c part committed by brian (1.37 of bin/ps/ps.c).  I'll update the
 > man page later today.
 
 The committed fix is half-baked at best.  It does't even remove the
 session keyword like the first version of the PR does.
 
 Kirk also removed the tsess pointer and keyword from everywhere except
 ps.1, but the PR doesn't mention it.  The log message for rev.1.25 of
 keyword.c says the following about the removal:
 
     kernel/user interface, specifically rusage and rtprio. It no
     longer contains proc, session, pcred, ucred, procsig, vmspace,
     pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If
     any of these changed in size, ps, w, fstat, gcore, systat, and
     top would all stop working. The new structure has over 200 bytes
 
 This is incorrect for "session" in ps at least.  ps would not have
 stopped working if sizeof(struct session) changed, since it just
 printed the session pointer.
 
 Bruce
 
>Unformatted:
