• 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: How do I find out if a process is running if I have the process Name?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I find out if a process is running if I have the process Name?


  • Subject: Re: How do I find out if a process is running if I have the process Name?
  • From: John Stiles <email@hidden>
  • Date: Thu, 18 May 2006 10:16:37 -0700

On May 18, 2006, at 9:27 AM, Nick Zitzmann wrote:


On May 18, 2006, at 9:51 AM, Scott Mitchell wrote:

But what I need to do is, given a process name (Application or other type), how can I find out if that process is running.

Please search the list archives for sysctl.

Honestly, I had a similar question posted a month or three ago, and the answer really is very non-trivial. I think it's a fair thing to ask, considering my thread never really came across one plain "this is how you do it, no exceptions" answer.


[NSApplication launchedApplications] works if you only care about GUI apps. And it's really easy to use.
Carbon Process Manager works if you only want apps that connect to the Window Server. (This covers a bit more ground than Cocoa because it includes LSUIElement-style apps.) This is also pretty darn easy to use but it lacks a few of the niceties of Cocoa (e.g. NSEnumerator).
sysctl works if you don't mind using an "unstable" API and potentially breaking in a future OS X release. For some of us that's acceptable; for others it's not OK.
You can also use Mach APIs if you have root access. I don't remember many of the details here. I believe Activity Monitor works this way; it launches a tool with the "run with root privs" bit set.


AFAIK none of these solutions work quite right if you move or rename the app after it has been launched. You will get back the path that it was originally launched from. This is a sad downgrade from OS 9 but I guess it is a hard problem to solve.

I ended up using the Process Manager since I didn't want to deal with root access or potentially unstable APIs.
_______________________________________________
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: How do I find out if a process is running if I have the process Name?
      • From: Ondra Cada <email@hidden>
References: 
 >How do I find out if a process is running if I have the process Name? (From: Scott Mitchell <email@hidden>)
 >Re: How do I find out if a process is running if I have the process Name? (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: URI de/encoding
  • Next by Date: Re: URI de/encoding
  • Previous by thread: Re: How do I find out if a process is running if I have the process Name?
  • Next by thread: Re: How do I find out if a process is running if I have the process Name?
  • Index(es):
    • Date
    • Thread