On Thu, Dec 16, 2010 at 08:22:41AM -0500, no-re...@cfengine.com wrote:
>Forum: Cfengine Help
>Subject: Re: Overriding ps option string in 3?
>Author: neilhwatson
>Link to topic: https://cfengine.com/forum/read.php?3,19802,19811#msg-19811
>
>I'm no programmer but I can't help but think that there must be a better way 
>to read the process table than relying on the ps utility.  Perl has more than 
>one process table reader.  How do they do it?

On operating systems that support the /proc filesystem this is typically
queried directly.  I know that this is true on Linux boxes, and I
suspect the same is true for Solaris and perhaps others.  An OpenBSD 4.1 box
I have has to do something, I think via sysctl() calls, but don't quote
on that.

On one hand, I agree that processing 'ps' is kinda kludgy, and will
impose a (slight) performance hit since you have fork/exec a process to walk
the process tree, instead of just walking the process tree.  

On the other hand, the output for 'ps' is semi-standard, and it's
"merely" a matter of string processing.

Dig deeper into those perl modules, and I think you'll find that they
have a combination of OS detection (for /proc), directory walking, and
'ps' output processing.

-- 
Jesse Becker
NHGRI Linux support (Digicon Contractor)
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to