From: Devin Mullins Date: 2006-11-29T23:40:12+09:00 Subject: Re: I'm a process-spawning idiot. For reference's sake, I don't need fork. The same trick works with Kernel#system. Some ugly code: inp, out = IO.pipe # start Thread.critical old_stdout = STDOUT.dup STDOUT.reopen out system 'echo', 'matz is nice!' STDOUT.reopen old_stdout # end Thread.critical out.close puts "Hey guess what: #{inp.read}" __END__ Out of curiosity, is this one of those places where I'd _have_ to use Thread.critical (assuming I don't want other threads putsing to my pipe)? Devin Devin Mullins wrote: > This Ruby program: > STDOUT.reopen open('log.txt','w') > exec 'echo', 'Hi!' > __END__ > outputs "Hi!" to log.txt. > > shell.rb (or, more specifically, shell/process-controller.rb), uses this > combined with fork (since exec replaces the process) to do its dirty work. > > Downloading win32-process now... :D