Monday, January 28, 2019

Forking Example

puts "Parent process id : #{Process.pid}"

TEST = 10
fork do
  puts TEST
  puts "---- Child process id : #{Process.pid}"  
  puts "---- Parent process id : #{Process.ppid}"
end

fork do
  puts TEST
  puts "**** Child process id : #{Process.pid}"  
  puts "**** Parent process id : #{Process.ppid}"
end


puts TEST
puts "Waiting for child to exit"
Process.wait
puts "Done"


at_exit do
  puts "About to exit the program"  
end