Re: Is this program open?
Re: Is this program open?
- Subject: Re: Is this program open?
- From: Ali Ozer <email@hidden>
- Date: Thu, 13 Apr 2006 10:43:10 -0700
[NSWorkspace launchedApplications] will give you the list of running
apps, which you can query by bundle ID or path. But that does not
include command line tools.
Ali
Begin forwarded message:
From: John Stiles <email@hidden>
Date: April 13, 2006 10:32:00 AM PDT
To: Cocoa List <email@hidden>
Subject: Is this program open?
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 know how to walk the running-process list with the Process
Manager, so I suppose I could make a map containing paths to each
running app, and then check each file's path to see if it's in the
map. But is that really the best way to go? It seems like the OS
must already know this information somewhere!
BTW, I tried opening the executable with read/write permission, but
that actually succeeds! You can open it up, rewrite the bits, and
amazingly everything still works—the app keeps on trucking until you
quit it. (When you reopen it the next time, of course it runs the
new version :) )
Unix is kind of amazing sometimes.
(NOTE: a similar question was posed on Carbon-Dev, but I didn't get
any replies...)
_______________________________________________
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