Hi:

Is there a way to get data back from a fork?
Here is a little code snippet. I think I understand
what it is doing and why it is not working, but
I don't have much experience in this area.

class Batch
 def initialize
   @Job = Struct.new("Job", :pid, :result, :cmd)
   @job_table = {}
 end

 def launch
   job.pid = Process.fork { redirect(job) }
   @job_table[pid] = job
 ensure
   wait
 end

 def redirect(job)
   .. setup stuff
   job.result = system(job.cmd)
 end

 def wait
  loop {
    begin
      pid, rtn_status = Process.wait2
      job = @job_table[pid]
      job.result                      #=> is empty
    rescue StandardError => err
      break
    end
  }
 end
 
 def add_command
   ...add command
 end
end#class Batch

I want to be able to store the result status from the system
call, but setting it inside redirect does not seem to work.
I checked and the objects have the same id, so I am
not sure why I can't set the result status.

Any info would be greatly appreciated.

Thanks
-- 
Jim Freeze
If only I had something clever to say for my comment...
~