• 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: NSTask arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask arguments


  • Subject: Re: NSTask arguments
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 20 Feb 2013 22:41:32 -0600

On Feb 20, 2013, at 10:31 PM, Kyle Sluder wrote:

> On Feb 20, 2013, at 8:30 PM, Jens Alfke <email@hidden> wrote:
>
>> On Feb 20, 2013, at 8:22 PM, Kyle Sluder <email@hidden> wrote:
>>
>>> You can accomplish this without writing to the file system, but it
>>> involves foregoing NSTask. Fork, close stdin in the child process, open
>>> a pipe (so that the child gets the read end in fd 0), then exec the tool
>>> with "/dev/stdin" as the filename argument.
>>
>> D’ohh! I’d forgotten about /dev/stdin. But why does this require abandoning NSTask? Its API supports redirecting input/output. Just call -[NSTask setStandardInput:].
>
> Because you can't use CF (and by extension, Foundation) after calling fork.

But with NSTask and NSPipe a) it's all taken care of for you, you don't need to do anything yourself after the fork; and b) it using pipe() and either fork()+exec() or posix_spawn() behind the scenes anyway.  There's no use of high-level frameworks required in the subprocess.

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: 
 >NSTask arguments (From: email@hidden)
 >Re: NSTask arguments (From: Jens Alfke <email@hidden>)
 >Re: NSTask arguments (From: Kyle Sluder <email@hidden>)
 >Re: NSTask arguments (From: Jens Alfke <email@hidden>)
 >Re: NSTask arguments (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: How to recognize mutability?
  • Next by Date: Re: How to recognize mutability?
  • Previous by thread: Re: NSTask arguments
  • Next by thread: Re: NSTask arguments
  • Index(es):
    • Date
    • Thread