On Mar 28, 2010, at 12:06 PM, John Pannell wrote:

> Hi James-
> 
> Depending on your use case, you might be able to shut the buffering off by 
> something like this...
> 
> setvbuf(stdout, NULL, _IONBF, 0);


That would go in the command line tool, not in the client app, right?  As I 
mentioned, I don't have source code for the tool.


> On Mar 28, 2010, at 12:56 PM, James W. Walker wrote:
> 
>> 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 (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/john%40positivespinmedia.com
>> 
>> This email sent to j...@positivespinmedia.com
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to