• 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: NSFileHandle stdin sends ∞ notifications of 0 bytes available
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileHandle stdin sends ∞ notifications of 0 bytes available


  • Subject: Re: NSFileHandle stdin sends ∞ notifications of 0 bytes available
  • From: Greg Parker <email@hidden>
  • Date: Thu, 12 Jun 2014 15:35:15 -0700

On Jun 12, 2014, at 3:24 PM, Jerry Krinock <email@hidden> wrote:
> I need to develop a tool which processes stdin as it arrives from its parent process.  The following code works as expected when it is in invoked with no stdin, that is…
>
> Air2:Debug jk$ ./MyTool
>
> But if I pipe some initial stdin to it, like this
>
> Air2:Debug jk$ echo Hello | ./MyTool
>
> after the initial notification and processing of “Hello”, the notification-handling block infinitely receives repeated, different notifications, for which -availableData returns an empty data object.
>
> I can’t understand and cannot work around it.  Why am I getting infinitely repeated notifications when there is no data available?

You reached end of file.

"
availableData
Returns the data currently available in the receiver.
…
If the receiver is a communications channel, this method reads up to a buffer of data and returns it; if no data is available, the method blocks. Returns an empty data object if the end of file is reached.
"

If you get back an empty data object you are at end of file, and you should not call -waitForDataInBackgroundAndNotify again.


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

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: NSFileHandle stdin sends ∞ notifications of 0 bytes available
      • From: Jerry Krinock <email@hidden>
References: 
 >NSFileHandle stdin sends ∞ notifications of 0 bytes available (From: Jerry Krinock <email@hidden>)

  • Prev by Date: NSFileHandle stdin sends ∞ notifications of 0 bytes available
  • Next by Date: Re: NSFileHandle stdin sends ∞ notifications of 0 bytes available
  • Previous by thread: NSFileHandle stdin sends ∞ notifications of 0 bytes available
  • Next by thread: Re: NSFileHandle stdin sends ∞ notifications of 0 bytes available
  • Index(es):
    • Date
    • Thread