Re: NSTask/NSPipe STDIN hangs on large data... (+ code question)
Re: NSTask/NSPipe STDIN hangs on large data... (+ code question)
- Subject: Re: NSTask/NSPipe STDIN hangs on large data... (+ code question)
- From: Daryn <email@hidden>
- Date: Fri, 24 Jan 2003 23:31:35 -0600
What I was actually suggesting, but I wasn't entirely clear, was to
send the input line by line (newline delimited), and to poll for output
after sending each line. That should generally avoid deadlock cases.
For polling, you can use fcntl(2) to set O_NONBLOCK on the file
descriptor, or use select(2) with a zero second timeout.
I think CFStreams might be worth investigating too.
On Monday, January 20, 2003, at 10:16 PM, Joe Pezzillo wrote:
Daryn-
Thanks for your insightful reply.
Based on your info regarding the pipe buffer size, I tried yet another
approach to the problem which was to not only chunk the STDIN data into
smaller chunks, but then to try and writeData + close to flush the
input
pipe after each chunk is written. However, even if I try to get the
Pipe and
its fileHandleForWriting before each write, once I've closed the
handle I
can't get it back, so the first chunk gets written but that's it
before an
exception is raised. Did you have another idea of how I could implement
around this 8KB buffer so I can send more data to (certain) UNIX
commands
via an NSTask/NSPipe? How would I do the output polling you mention
(quoted
below) other than via readInBackgroundAndNotify or a blocking read
loop?
Especially if the pipe hangs during the write command, I'll never get a
chance to poll for any output on STDOUT.
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.