• 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
NSTask and pseudo TTY
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTask and pseudo TTY


  • Subject: NSTask and pseudo TTY
  • From: "James W. Walker" <email@hidden>
  • Date: Sun, 28 Mar 2010 11:56:27 -0700

I've been running NSTask and reading the output using -[NSFileHandle readInBackgroundAndNotify], but in certain situations there was a problem:  Due to the block buffering of standard output, I wasn't getting notified as soon as some output had been produced.  I don't have control over the code being run by NSTask.  Some googling led me to believe that I need to use a pseudo tty instead of NSPipe to communicate with the NSTask.  So, I called openpty, wrapped the file descriptors in NSFileHandles, set the slave handle as standard output of the NSTask, and called [masterHandle readInBackgroundAndNotify].  This almost worked.  The problem is that I can't tell when the output is done.  When I was using NSPipe, my NSFileHandleReadCompletionNotification observer method would get an NSData of length 0, which told me that there was no more data.  Now, that doesn't happen.  I tried observing NSTaskDidTerminateNotification, but that notification arrives before I've received all the data.  Attempting to read more data with -[NSFileHandle availableData] just hangs.

Can anyone lead me out of this mire?

_______________________________________________

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

  • Follow-Ups:
    • Re: NSTask and pseudo TTY
      • From: Ken Thomases <email@hidden>
    • Re: NSTask and pseudo TTY
      • From: John Pannell <email@hidden>
  • Prev by Date: Re: Solving memory leaks
  • Next by Date: Re: NSTask and pseudo TTY
  • Previous by thread: Re: Creating WebView in code
  • Next by thread: Re: NSTask and pseudo TTY
  • Index(es):
    • Date
    • Thread