首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

Ruby过程(3) Process.fork 和 Ruby 1.9.2 中的新方法 Process.spawn的区别

2013-04-05 
Ruby进程(3) Process.fork 和 Ruby 1.9.2 中的新方法 Process.spawn的区别简单来说:Process.spawn Proce

Ruby进程(3) Process.fork 和 Ruby 1.9.2 中的新方法 Process.spawn的区别

简单来说:Process.spawn = Process.fork + exec?

?

Process.fork?allows you to run ruby code in another process.?Process.spawn?allows you to run another program in another process. Basically?Process.spawn?is like using?Process.fork?and then calling?exec?in the forked process, except that it gives you more options.

?

Use?fork?if you need to run arbitrary ruby code in a separate process (you can't do that with?spawn). Use?spawn?if you need to invoke an application in a subprocess.

?

Source:

http://stackoverflow.com/questions/4129196/whats-the-difference-between-process-fork-and-process-spawn-in-ruby-1-9-2

热点排行