On 24 oct. 2010, at 19:03, eveningnick eveningnick wrote:

> Hello!
> I am wondering, if  NSTask can be replaced with low-level fork/exec
> calls. Looking through forums, i often met statements that launching a
> process with "fork/exec" is not an "OS X way", especially if i am
> using Cocoa framework (and i am using Cocoa!).

Yes you can use fork/exec, that's what NSTask does.

> What i want to do - is to launch an application and just leave it
> running (i don't want to wait until it terminates, and i don't need
> its exitcode - my app spawns it and forgets about it, doing other
> jobs). Another condition - this application should be launched by
> executing its binary, rather than through emulation of a doubleclick
> on its *.app bundle (my bundle has several executables - maybe this
> also not Mac-way, but it is done for modularity and safety of the
> application, when one part crashes, the rest shouldn't crash - anyway,
> the visible behavior of my app is what user expects) - and I read that
> Launch Services doesn't support launching separate binaries - only
> bundles are supported.

Are you sure about that?

> What could be the pitfalls with using fork/exec method? I have found
> it's the most appropriate solution for me, though i don't have a lot
> of experience with Mac programming.
> 
> To avoid "Zombie processes" i am using double-forking
> (Parent->TemporaryProcess->Child, where TemporaryProcess exits right
> after its own forking, and Parent "waitpid"s for TemporaryPS to finish
> - as long as TemporaryProcess terminates, Child's parent becomes the
> root process).

Not great but should work.
Better would be to use LaunchServices, if not possible I would use 
SMJobSubmit() (ServicesManagement framework).


Thomas_______________________________________________

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

Reply via email to