What's the difference between Process.fork and Process.spawn in Ruby 1.9.2?

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.

What's the difference between Process. Fork and the new Process. Spawn methods in Ruby 1.9.2 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.

And which one is better to run another program in a subprocess? If you need backwards compatibility, use fork + exec as spawn is not available in 1.8. Otherwise use spawn since running another program in a subprocess is exactly what spawn is made for.As far as I understand Process. Fork accepts block of code and Process.

Spawn takes a system command plus some other parameters.Exactly. When I should use one instead of the other? 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.

I believe Process. Fork forks the current process, and Process. Spawn spawns a new process.

They are quite different. Do you want a new thread or a new process?

I need a new process and currently use Process. Fork (for background video encoding). I just found about the new Process.

Spawn method in Ruby 1.9 and was curious about the differences and if I can benefit from it somehow. – Vincent Nov 9 '10 at 0:09.

I think that would depend on the OS you are running on. If you are running on POSIX OS, you can use Process. Fork, instead if you are running on windows, you would do Process.spawn.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions