On 9 Dec 2009, at 00:14, Nick Zitzmann wrote: > On Dec 8, 2009, at 5:03 PM, 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]? > > Yes. ([[[NSProcessInfo processInfo] arguments] objectAtIndex:0])
No, no, no and thrice no. What that gives you is the content of argv[0], which *is not* (necessarily) the path to your program. If you think it is, then to disabuse you of the notion I can write a program like this: #include <unistd.h> int main (void) { execl ("/Applications/YourApp.app/Contents/MacOS/YourApp", "This is not my path", NULL); } and what you'll discover (probably to your horror) is that the above gives the result @"This is not my path" as for that matter would accessing argv[0] from your main() function. Obviously it's equally possible to substitute any old path rather than the string "This is not my path". It is possible to get the path to your executable using the dyld API, but before doing such a thing you need to be very clear as to why you need it and what it is that you're going to do with it. It's very easy to end up with major security holes or just plain broken behaviour. Kind regards, Alastair. -- http://alastairs-place.net _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com