Re: NSFileHandle stdin sends ∞ notifications of 0 bytes available
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