From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-05-14T08:38:44+09:00 Subject: Re: RCR for child execution On Wed, 14 May 2003 09:08:59 +0900, Brian Candler wrote: > On Tue, May 13, 2003 at 11:33:10PM +0900, Simon Strandgaard wrote: >> Does it answer the question ? > > No, because it cannot work. If I write > > s = "" > $stdout = StringIO.new(s) > pid = fork do > exec("ls *.txt") > end > Process.wait(pid) > > how are you going to modify fork or exec so that it captures the output of > 'ls' into the StringIO object created earlier? I luckyly forgot all about this senario... I you can forgive me :-) StringIO has no filedescriptor that fork() can parse down to the child. So we must create such filedescriptor. A pipe and a receiver thread in the parent process should do it. Some semaphore protection is probably necessary, But I don't have enough insight into the core of ruby, so I cannot tell where semaphore protection should go. I think this is possible. This will solve all my problems. Is such patch to ruby realistic ??? -- Simon Strandgaard