Re: Finding process path from Cocoa?
Re: Finding process path from Cocoa?
- Subject: Re: Finding process path from Cocoa?
- From: Alastair Houghton <email@hidden>
- Date: Wed, 9 Dec 2009 10:06:55 +0000
On 9 Dec 2009, at 00:03, Laurent Daudelin wrote:
> Is there any way I can find what's the path of a given process running? A background process, which cannot be retrieved in [[NSWorkspace sharedWorkspace] launchedApplications]?
If we're talking about background processes, to get this kind of information you probably need to use sysctl() (or run "ps" in the background and parse its output), however I think you'll find that you can only get the contents of the argv[] array, which can be set to *anything* by your parent process.
Furthermore, there is no guarantee that the executable will not have moved to a different location on the drive, or been replaced by a new (and potentially different) executable.
You might be interested in this (which I found using Google just now)
<http://www.nightproductions.net/dsprocessesinfo_m.html>
which is fine for displaying the information to the user, but I really wouldn't recommend using or relying on the pathname of your executable, or anyone else's for that matter.
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