Re: looking for System APIs for load monitoring
Re: looking for System APIs for load monitoring
- Subject: Re: looking for System APIs for load monitoring
- From: Jean-Daniel Dupas <email@hidden>
- Date: Tue, 18 Aug 2009 18:37:39 +0200
Le 18 août 2009 à 17:28, Terry Lambert a écrit :
On Aug 18, 2009, at 4:32 AM, Mo McRoberts <email@hidden> wrote:
On Tue, Aug 18, 2009 at 08:30, Marc Lohse<email@hidden>
wrote:
The kind of information i need is essentially what's supplied by
the ps -axv command.
Have you looked at the sources to ps or top? (e..g,
http://opensource.apple.com/source/top/top-39/)
Please be aware the the APIs used by these programs are considered
SPI, and are therefore unstable from software update to software
update, and, as I noted the other day, at least in Leopard, they are
not even guaranteed to be 64 bit clean. Portability of the code to
Tiger and earlier versions is also problematic, as the SPI in use
for this changed in that time frame (i.e. your code will not work on
all of Tiger, Leopard, and later simultaneously in all bitness, even
if you compile from source each time).
Despite what he wants or doesn't want, popen'ing the ps command and
using the POSIX mandated -A option for "all processes" and the POSIX
mandated -o option to control output formatting to make it easy to
parse the program output are your best bets to ensure binary
compatibility. We (a) have to maintain POSIX compliance for the ps
command, (b) will rev the ps command in lockstep with the changes to
the SPI, so you are reasonably assured it will keep working over SPI
changes, or be fixed quickly, (c) POSIX itself rarely changes the
list of supported options to command line commands, and (d) your
code will be portable to other POSIX compliant OSs, without
modification.
(e) you won't have to deal with permissions issues as ps is suid.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden