• 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: fork/exec vs NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fork/exec vs NSTask


  • Subject: Re: fork/exec vs NSTask
  • From: Ken Thomases <email@hidden>
  • Date: Sun, 24 Oct 2010 15:15:30 -0500

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 (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: 
 >fork/exec vs NSTask (From: eveningnick eveningnick <email@hidden>)

  • Prev by Date: Re: fork/exec vs NSTask
  • Next by Date: NSMutableURLRequest google my maps help
  • Previous by thread: Re: fork/exec vs NSTask
  • Next by thread: Re: fork/exec vs NSTask
  • Index(es):
    • Date
    • Thread