From: trickyvail <7ricky@...> Date: 2008-07-15T08:50:25+09:00 Subject: Re: open3 throws exception when preceded by fork On Jul 14, 2:52 pm, "ara.t.howard" wrote: > require 'rubygems' > require 'slave' # gem install slave > > class Server > def run job > system job > end > end > > slave = Slave.new{ Sever.new } > server = slave.object > > server.run 'echo "this is in another process you do not have to ever > worry about"' Thank you for you reply. Unfortunately I am unable to utilize the slave ruby gem (and open4 gem also) due to some rubygems package corruption? on my Ubuntu machine. I've given up fighting with it and come up with a different solution. daemon: #!/usr/bin/ruby stop = false Signal.trap('CLD') do child = Process.wait puts "child #{child} closed." stop = true end exec('./job.rb') if fork.nil? while(! stop) puts 'not finished, do some other stuff' sleep 5 end puts "finished" job: #!/usr/bin/ruby require 'open3' stdin, stdout, stderr = Open3.popen3('real_job_binary') stderr.each do |line| puts line end This way the calls to fork and open3 are isolated in different ruby interpreter instances where they can't interfere with each other.