From: Sean O'Halpin Date: 2012-06-30T07:03:17+09:00 Subject: Re: Asynchronous IO Hi, > Currently I'm using OI.popen to open a new pipe to another process, and > I feed commands to it; but sometimes the other process could run for > multiple minutes before closing the pipe; and only at that stage can I > then see the output. Now, what I really need is to see the output of the > process as it writes to stdout already and not only when closing the > pipe? I just so happen to have been mucking about with the PTY (pseudoterminal) library under ruby 1.9.3. A pseudoterminal might be what you need if you can't change the buffering of the programs you're trying to manage. I've put my current test script here: https://gist.github.com/3020873 You'll need to play with the options to get the result you want - there's no really generic way to automatically manage interactive programs that expect to interact with a person. I've found it useful to run the test script in one terminal with the --debug option and in another use tail -F dbg.log to see exactly what is passing between the parent and the child process. As an example you could look at the differences between: ./pty-test.rb --debug irb --simple-prompt ./pty-test.rb --debug --raw irb --simple-prompt ./pty-test.rb --debug --errpipe --raw irb --simple-prompt Another one to try is ./pty-test.rb --debug --errpipe --raw vi Regards, Sean