fork with Ruby 1.8 and Windows

人走茶凉 提交于 2019-12-06 15:11:43

Like that:

if child = fork
  puts 'parent'
  Process.wait
  puts 'done'
else
  puts 'child'
end

I found a little makeshift. It works like its supposed to be when I add Process.kill(1, 0) at the end of the child block. But I think it's not the best solution. So I'd still be happy if someone knows a real solution.

I think you just need Process.exit! before you end your fork.

fork do
  puts 'child'
  Process.exit!
end
puts 'parent'
Process.wait
puts 'done'
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!