Re: Better way than GetNextProcess()?
Re: Better way than GetNextProcess()?
- Subject: Re: Better way than GetNextProcess()?
- From: John Stiles <email@hidden>
- Date: Tue, 22 May 2007 17:25:57 -0700
On May 22, 2007, at 5:20 PM, Bob Clark wrote:
On May 22, 2007, at 2:32 PM, Kam Dahlin wrote:
I have a background only app that I need to be able to check to
see if it is running. I have been looking for some nice simple
cocoa calls for this, and [[NSWorkspace sharedWorkspace]
launchedApplications] looked like the way, but it doesn't show
hidden apps. In my research I have run across GetNextProcess()
and it seems to be able to do what I want. However, it is going
to be a bit more involved so before I go and make that call work I
wanted to ask here if there was a better way for getting a list of
running applications, including those that are hidden?
Hi Kam.
If your background-only app really is an application, linked to
cocoa and/or carbon frameworks, then iterating through
GetNextProcess should work. But if it's actually a BSD level
program (a daemon or something you'd often run from the command
line) then it won't be registered as a process that the Process
Manager knows about. In that case you'll have to iterate over all
processes using sysctl().
http://developer.apple.com/qa/qa2001/qa1123.html
Even this technique isn't really usable because of a note in QA1361:
IMPORTANT: Because the definition of the kinfo_proc structure (in
<sys/sysctl.h>) is conditionalized by __APPLE_API_UNSTABLE, you
should restrict use of the above code to the debug build of your
program.
http://developer.apple.com/qa/qa2004/qa1361.html
Basically I think this struct can change between major OS releases so
you can't rely on it for shipping code.
(I filed a bug on QA1123 mentioning this but it's been open for eons
without any change in status.)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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