Returning data from forked processes

fork, process, ruby

Solution

I wrapped all the solutions I found along the way (some other problems like user exiting + piping-buffers) into ruby parallel gem. Now it is as easy as:

results = Parallel.map([1,2,3],:in_processes=>4) do |i|
  execute_something(i)
end

or

results = Parallel.map([1,2,3],:in_threads=>4) do |i|
  execute_something(i)
end

Problem

If I do ``` Process.fork do x end ``` how can I know what x returned (e.g. true/fase/string) ? (Writing to a file/database is not an option...)

Original source