From: Guillaume Marcais Date: 2003-05-08T03:23:39+09:00 Subject: Re: capture output What about something like this. You start a ruby process in C++ in its own pseudo-tty, so that all output (stdout and stderr) of ruby and ruby's subprocesses is sent to the tty. To execute snippets of ruby code, simply write them to the ruby interpreter. And there is always one ruby interpreter, no child. Example of codes: Start the ruby interpreter int mtty; /* Master tty descriptor */ FILE *fd; switch(forkpty(&mtty, NULL, NULL, NULL)) { case -1: exit(1); case 0: execl("/usr/bin/ruby", "ruby"); break; default: fd = fdopen(mtty, "r+"); } Send command to the interpreter: fputs(fd, "system(\"echo Hello\")\n"); Read output: char buff[1024]; fgets(buff, 1024, fd); /* buff == "Hello" */ Hope that helps, Guillaume. NB: thist *should* work on Linux. For linking, you need -lutil. On Wednesday 07 May 2003 08:57 am, you wrote: > On Wed, 07 May 2003 22:22:27 +0900, Brian Candler wrote: > > On Wed, May 07, 2003 at 08:16:44PM +0900, Simon Strandgaard wrote: > >> How does other applications do this redirection ? > > > > I think I have answered this several times already! > > Yes.. I think we have a human-communication problem here (broken-pipe) > Im not a native english speaker and im having reduced sight.. > and im worried that you don't have caught my question right ;-) > maybe there is more reasons? > > > The only thing is, as far as I know, IO.popen will not attach both stderr > > and stdout to the same pipe. You can submit that as a feature request. > > I have never tried filing a RCR and I have no expert knowledge > about the exact problem.. I think its better you do it ?