Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Mar 2001 22:50:03 -0800 (PST)
From:      Dima Dorfman <dima@unixfreak.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/26057: [PATCH] Minor ps(1) fixes 
Message-ID:  <200103250650.f2P6o3D58999@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/26057; it has been noted by GNATS.

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

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103250650.f2P6o3D58999>