Re: Modern way of getting the list of running applications?
Re: Modern way of getting the list of running applications?
- Subject: Re: Modern way of getting the list of running applications?
- From: Alastair Houghton <email@hidden>
- Date: Tue, 10 Jul 2007 00:03:17 +0100
On 9 Jul 2007, at 22:16, Stéphane Sudre wrote:
Following a discussion of some utility on another mailing list, I
was wondering if there was a new modern way to get the list of
running applications without using:
- the Carbon Process Manager
- the creator / CFBundleSignature of an application
?
A 'ps' wrapper is not a solution since it does not provide accurate
information (relative path vs absolute path for instance).
At the BSD layer, you can use the KERN_PROC sysctl() to obtain a list
of kinfo_proc structs. The last time I used this method (because I
wanted to see *all* processes, not just visible applications), I
think I resorted to the Process Manager to find the bundle
corresponding to a BSD pid (i.e. GetProcessForPID(), then
GetProcessBundleLocation(), and finally FSRefMakePath() to get back
to a path).
I remember feeling disappointed that there didn't seem to be another
way to get from a pid to a bundle.
It looks as if the Process Manager calls through to a set of
undocumented APIs with the prefix "CPS" (there appear to be some apps
using one or two of these calls right now, and the guess is that
"CPS" stands for Core Process Services). It's a shame that these
aren't documented, because it looks as if I the CPS APIs can give a
path for the process's bundle, which the Process Manager
GetProcessBundleLocation() API converts to an FSRef only for my code
to change it straight back to a path again.
Someone even posted a header for the CPS APIs on Cocoadev:
http://www.cocoadev.com/index.pl?CoreProcessServices
Anyway, maybe we should file some Radars requesting access to the CPS
API?
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden