NSTask and child process buffering.
NSTask and child process buffering.
- Subject: NSTask and child process buffering.
- From: Chris Gehlker <email@hidden>
- Date: Wed, 20 Feb 2002 22:35:23 -0700
I'm working on an IDE for Ruby and I'm having a problem where the thread
that reads output from Ruby blocks on
[stdOutHndl availableData]
Or
[stdOutHndl readDataToEndOfFile]
Where stdOutHndl is an NSFileHandle associated with an NSPipe connected to
Ruby's standard output. This happens when waiting for interactive Ruby
programs to output a prompt. Ruby is running as an NSTask with pipes
connected to stdin, stdout and stderr.
I can fix this on the Ruby side by writing ruby programs like:
$stdout.print "Enter a string:"
$stdout.flush
a = $stdin.gets
But if I comment out the $stdout.flush my Cocoa program never sees the
prompt.
So far there is nothing mysterious. By IDE is blocking because Ruby hasn't
flushed it's buffers. Where it gets mysterious is that few Ruby programs
bother with the flush and they work from the command line. Indeed the code
fragment above will run fine from tcsh without the flush. So my question is
"How does tcsh get child processes to turn off buffering and how do I
replicate that in an NSTask?
You knew I'd bring it aroun to Cocoa eventually. :)
--
I have discovered that all human evil comes from this, man's being unable
to sit still in a room. -Blaise Pascal, philosopher and mathematician
(1623-1662)
_______________________________________________
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.