fork/exec vs NSTask
fork/exec vs NSTask
- Subject: fork/exec vs NSTask
- From: eveningnick eveningnick <email@hidden>
- Date: Sun, 24 Oct 2010 21:03:31 +0400
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!).
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.
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).
Basically this is the question about using fork in MacOS. But if there
are other ways to launch a process, i'd appreciate if someone shared
:)
Thanks for the answer!
_______________________________________________
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