Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Mar 2004 21:05:25 -0500
From:      Garance A Drosihn <drosih@rpi.edu>
To:        arch@freebsd.org
Cc:        Julian Elischer <julian@elischer.org>
Subject:   Re: Questions on `pgrep' and `pkill'
Message-ID:  <p06020481bc893b6e2b4d@[128.113.24.47]>
In-Reply-To: <p0602046abc879c5fe2f9@[128.113.24.47]>
References:  <p0602046abc879c5fe2f9@[128.113.24.47]>

next in thread | previous in thread | raw e-mail | index | archive | help
Well, I have added pkill & pgrep to src/usr.bin, and have it
pretty much working (thanks to lioux, who had already done all
the real work in the port for sysutils/pkill).

I have two minor questions.

For the 5.x-branch, I assume that:

	plist = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nproc);

should be asking for KERN_PROC_PROC.  Or should I add an `-H'
option to govern that?  Would it make any sense for these commands
to list out threads?  (or it would it make sense for `pgrep' but
not for `pkill'?  I have no experience with threaded processes...)

The other question is just something I'm confused about.  I have
my own little "psgrep" script, so once I had `pgrep' working I
compared what my script does to the new command.  It happens that
I'm running OpenAFS on this machine, and here's basically what I
got:

(35) psgrep afsd
   641 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   642 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   643 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   644 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   645 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   646 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   647 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   648 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   649 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...
   650 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...

(36) pgrep -fl afsd
644 /usr/local/sbin/afsd -stat 1200 -dcache 800 ...

I don't understand why pgrep matched only one of these.  If you
turn on the `-D' option that I added to pgrep, it seems that all
the rest of those afsd processes have the P_SYSTEM flag set.  Why
would all of those processes but one have that flag set?  Or why
doesn't that one *also* have it set?  It isn't even the first or
last process that was started up.

This wasn't the behavior I would expect.  Are there some other
flag(s) I should be checking for whatever these commands are
using P_SYSTEM for?  (I think we'll all be better off if I don't
try to become a kernel developer to answer this...)

-- 
Garance Alistair Drosehn            =   gad@gilead.netel.rpi.edu
Senior Systems Programmer           or  gad@freebsd.org
Rensselaer Polytechnic Institute    or  drosih@rpi.edu



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