From: Brian Candler Date: 2003-05-07T21:22:27+09:00 Subject: Re: capture output On Wed, May 07, 2003 at 08:16:44PM +0900, Simon Strandgaard wrote: > > The problem is this: you are forking a child process, which inherits > > stdin/stdout/stderr. It then writes to them using *Unix* write() calls, to > > file descriptors 1 (stdout) and 2 (stderr). > > > > Now, you can redirect fds 1/2 to a file before forking, in which case the > > child will write to that file. But you cannot redirect those fds to a Ruby > > object, because the Unix write() syscall does not call Ruby! > > Im no expert on this either.. thus im asking :-) > VIM can execute a child process and capture its output. Yes: it opens a pipe, forks, and passes one end of the pipe as stdout (and/or stderr) to the child. In Ruby, that's IO.popen. > How does other applications do this redirection ? > I cannot believe that this is NOT possible with ruby ??? I think I have answered this several times already! 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. Brian.