Re: Finding process path from Cocoa?
Re: Finding process path from Cocoa?
On 9 Dec 2009, at 09:53, Alastair Houghton wrote:
>>
>> 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);
> }
The docs for execl(3) do state the convention:
The first argument, by convention, should point to the file name associated with the file being executed.
This being a Cocoa list we should expect that all conventions are being followed to the letter, by everyone, everywhere (though in this case I wouldn't bet the farm on it)._______________________________________________
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