• 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: exec(uting) Safari - How (newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exec(uting) Safari - How (newbie)


  • Subject: Re: exec(uting) Safari - How (newbie)
  • From: "Clark Cox" <email@hidden>
  • Date: Wed, 2 Jul 2008 09:45:36 -0700

On Wed, Jul 2, 2008 at 8:46 AM, Jason Coco <email@hidden> wrote:
>
> On Jul 2, 2008, at 11:38 , Clark Cox wrote:
>
>> On 7/2/08, Jason Coco <email@hidden> wrote:
>>>
>>> Yeah, to me it is... although I still agree that it's not an ideal
>>> solution for a Cocoa application...
>>>
>>> By the way, assuming you change char *args[] = { "-a", "Safari",
>>> NULL }; to char *args[] = { "/usr/bin/open", "-a", "Safari", NULL };
>>> the exec* example actually works while the LaunchServices example
>>> fails with kLSApplicationNotFoundError.
>>>
>>> After playing around with it a little, I discovered that you need to
>>> actually call it CFSTR("Safari.app") in this case to get it to work
>>> correctly... so like anything else in life, since I'm much more
>>> familiar with the POSIX/BSD API (and since pretty much every operating
>>> system I've ever worked with treats exec* similar) it's a lot easier
>>> *for me* than using LaunchServices.
>>
>> Easy or not, it's still wrong. Launching safari via exec will not, for
>> example, re-use an already/running instance.
>>
>> Just don't use exec to launch GUI applications--period.
>
> I don't think anyone disagrees with that... that's why the suggestion was to
> use /usr/bin/open if you were gonna use an exec* call. If you use
> /usr/bin/open it makes a proper connection to the window server as well as
> sending the proper apple event to an already-started application.

But why exec an external tool, when you can just call the API directly?

Exec'ing /usr/bin/open to launch Safari is akin to using popen("cat -
> filename", "w"), and piping data to it whenever you need to write a
file, instead of just using open/write (or fopen/fwrite).


--
Clark S. Cox III
email@hidden
_______________________________________________

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

References: 
 >exec(uting) Safari - How (newbie) (From: "Barrie Green" <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: Jason Coco <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: "Kyle Sluder" <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: Kevin Elliott <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: "Kyle Sluder" <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: Jason Coco <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: Jean-Daniel Dupas <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: Jason Coco <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: "Clark Cox" <email@hidden>)
 >Re: exec(uting) Safari - How (newbie) (From: Jason Coco <email@hidden>)

  • Prev by Date: tracking area problems on 10.4.11
  • Next by Date: Program design decision
  • Previous by thread: Re: exec(uting) Safari - How (newbie)
  • Next by thread: Re: exec(uting) Safari - How (newbie)
  • Index(es):
    • Date
    • Thread