Re: NSTask/NSPipe STDIN hangs on large data...
Re: NSTask/NSPipe STDIN hangs on large data...
- Subject: Re: NSTask/NSPipe STDIN hangs on large data...
- From: Daryn <email@hidden>
- Date: Wed, 29 Jan 2003 20:12:21 -0600
On Wednesday, January 29, 2003, at 06:08 PM, Joe Pezzillo wrote:
Of course, I thought that's what "readInBackgroundAndNotify" was
supposed to
deal with in the first place for the Asynch version.
Once blocked on a write, the run loop will grind to a halt. You might
try spinning off another thread with the read file handle and have that
thread read the output. I doubt NSTask is thread-safe, but I wouldn't
expect any problems with the file handles.
fileStatus = fcntl([readHandle fileDescriptor], F_SETFL, O_NONBLOCK);
... but then if I try to read right away, I get a "Resource temporarily
unavailable" exception. ...
I guess NSFileHandle doesn't like 0-length reads or the EAGAIN error...
It's rather odd that NSFileHandle doesn't include non-blocking support.
So then I tried using select() based on its manpage,
readyFDs = select( 1, &fdreadset, nil, nil, &zeroTV );
Your first arg to select() is causing only fd 0 (stdin) to be checked.
Trying passing [readHandle fileDescriptor]+1. I'd recode that into a
selector like -(BOOL)hasAvailableData to make it more palatable.
I truly appreciate all the time you've taken to help me with this, your
insights are very valuable. If you can suggest a book or online
reference
for this stuff, I'll gladly devour it and spend another day testing
before
asking any more questions!
Almost any O'Reilly book is good. It's a bit costly ($70), but if you
really want to learn unix, I'd told that Richard Steven's Advanced
Programming in the UNIX Environment is a great book. Also try googling
for "unix pipe read write deadlock".
Daryn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.