On Oct 24, 2010, at 12:03 PM, eveningnick eveningnick wrote:

> 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).

It's easy enough to launch an NSTask and not wait for it.  Just discharge 
whatever ownership responsibilities you have received, as per proper memory 
management techniques.  That is, if you used a method which gave you ownership 
responsibilities, like +alloc, then invoke -release to balance it.  After that, 
just forget it.

Really, it can be as simple as one line:

        [NSThread launchedTaskWithLaunchPath:@"/path/to/program" 
arguments:[NSArray array]];

Regards,
Ken

_______________________________________________

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