Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Carbon Run Command



Another difference between fork/exec and a LaunchServices launch is who ends up being the parent process and what sideetfects that has.

Processes launched by LS are parented by the WindowServer, but if you fork/exec a process from your app, its parent process is your app. Not only does that mean that the sublaunched app will die when your app quits, but also on launch the kernel will clone your entire process environment--env vars, open file descriptors, the works--for the forked app. This can be expensive. In Leopard you can use posix_spawn to reduce the impact of this, but it's still very different from launching an app in the Finder, which is what LaunchServices is like.

Chris

Sent from my iPhone

On Aug 9, 2007, at 6:40 PM, Ingemar Ragnemalm <email@hidden> wrote:

John Stiles wrote:
On Aug 9, 2007, at 6:11 PM, Ingemar Ragnemalm wrote:

Chris Hanson wrote:

Either use LaunchServices or NSWorkspace for applications, or fork/ exec or NSTask for command-line tools.

Is there any particular reason not to use fork/exec for GUI applications?

I'd say one significant concern is that if the app is already open, you will make a separate instance of it, which is not correct Mac OS behavior.

OK, that makes sense. (Fortunately it does not matter for my current use, but when it does I'll try LS.)


What I like about fork/exec is that it is portable and very future safe. I kind of wonder how hard it would be to add a check for duplicates.

(I get a feeling we have discussed this before. The argument feels familiar.)


/Ingemar

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Carbon Run Command (From: Ingemar Ragnemalm <email@hidden>)
 >Re: Carbon Run Command (From: John Stiles <email@hidden>)
 >Re: Carbon Run Command (From: Ingemar Ragnemalm <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.