From: Robert Klemme Date: 2009-03-18T06:27:30+09:00 Subject: Re: does IO.read block? On 17.03.2009 21:09, Michael Malone wrote: >>> I borrowed it from a process detach method elsewhere, so it might >>> not be exactly what I want. However, it had no effect. The problem >>> still exists. >> I do not know whether you plan to exec your forked process but if so >> you can make your life much easier by using Open3. Then you can do >> >> # from memory >> require 'open3' >> Open3.popen "cmd args" do |in,out,err| >> out.puts "foo" >> end >> > I'm not running a command as such, I'm running a block of code. Also, I > have come to the conclusion that I actually don't care about the output > in the child process. Is there an easy way to redirect to /dev/null? Please take a look at http://pastie.org/419160 for an answer to that as well as experimental script. >> I'd rather ask: what is the problem you are trying to solve? I still >> lack the big picture - we're talking about details here all the time >> but it's difficult to stay on track when the context is missing. > > Sorry, I was trying to ask specific questions rather than asking the > good folks on ruby-talk to debug my script for me entirely. I am > writing a thread pool, which accepts jobs as block parameters and by > calling run_process(&block) the job is run in an entirely new process, > with the thread from the pool calling fork(), creating a pipe to > transfer any exception objects back to the parent (hence the 4th pipe) > and then waiting to collect the child thread's status. The main use of > this is for compiling concurrently with the thread pool, then linking > concurrently with the process option. But in that case you only need a single pipe because all you want to transport back is the result of calculation, correct? And you could leave stderr untouched to get any error messages that you do not expect to the console. Another alternative would be to use DRb for the communication. Cheers robert