• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is this program open?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this program open?


  • Subject: Re: Is this program open?
  • From: John Stiles <email@hidden>
  • Date: Thu, 13 Apr 2006 11:01:43 -0700

I'd much rather use the Carbon Process Manager then shell out to a command-line tool. That sort of thing gives me the heebie-jeebies.
Then again, it seems like you need to have your "runs-as-root" bit set to get all the info; I looked at Activity Monitor and found it relies on a helper tool "pmTool". It has the "run-as-root" bit set and uses apparently-undocumented Mach calls. Gah. I didn't expect this to be hard :) Maybe I don't have a choice?



On Apr 13, 2006, at 10:56 AM, I. Savant wrote:


You could always experiment with NSTask, running the "ps" command ... option "w" gives you the full path, I believe. "-auxw" will give you all processes, including their paths.


--
I.S.


On Apr 13, 2006, at 1:46 PM, John Stiles wrote:

On Apr 13, 2006, at 10:41 AM, Tom Harrington wrote:

On 4/13/06, John Stiles <email@hidden> wrote:
Given a path (or FSRef/NSURL/whatever) to an application's executable:
/Volumes/MyHD/MyApp.app/Contents/MacOS/MyApp


I want to check to see if this executable is running, hopefully in a
semi-lightweight way (I may be doing this several times for different
apps). It would be cool if the same technique worked for command- line
tools too, but that's not a strict requirement.


Is there a way to accomplish this, using either Cocoa, Carbon or
lower-level Posix calls? (Technically, Posix would be a little better
fit for us, since we could avoid forking the code. Either way is
fine, though.)

I think you want to look at [[NSWorkspace sharedWorkspace]
launchedApplications]. Then scan the resulting dictionaries for your
path-- in the NSApplicationPath key.


I'm sure it's possible in Carbon, but that's the obvious Cocoa starting point.

I experimented with -launchedApplications in the past, but it had a lot of limitations—it only displayed apps that are end-user visible. Things like faceless apps and command line tools weren't included.
What does Activity Monitor use? It can even see other users' apps. That would be ideal for me.



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Is this program open?
      • From: Uli Kusterer <email@hidden>
References: 
 >Is this program open? (From: John Stiles <email@hidden>)
 >Re: Is this program open? (From: "Tom Harrington" <email@hidden>)
 >Re: Is this program open? (From: John Stiles <email@hidden>)
 >Re: Is this program open? (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: equivalent of "self" for willChangeValueForKey:/didChangeValueForKey:
  • Next by Date: Re: Is this program open?
  • Previous by thread: Re: Is this program open?
  • Next by thread: Re: Is this program open?
  • Index(es):
    • Date
    • Thread