Process.create equivalent on ubuntu

hello everyone

I am currently stuck with the Ruby process

I was previous working on windows and with the help of win32-process gem
I was able to achieve this

starter = ‘ruby test.rb’

pid = Process.create(:app_name => starter)

this work fine under windows

Now in ubuntu when i am trying to achieve this same thing with fork
it doesn’t work

the ruby code under ubuntu is like this

starter = ‘ruby test.rb’
pid = Process.fork {starter}

is there something that i am missing any where

thanks anyway

On 18 Jun 2009, at 13:08, Virendra N. wrote:

this work fine under windows

Now in ubuntu when i am trying to achieve this same thing with fork
it doesn’t work

the ruby code under ubuntu is like this

starter = ‘ruby test.rb’
pid = Process.fork {starter}

is there something that i am missing any where

The easiest approach:

starter = ‘ruby test.rb’
pid = spawn starter
Process::waitpid2 pid # if you want to wait on the process to
finish

or if yo want more flexibility:

starter = %w{ruby test.rb}
exec *starter unless pid = fork

There’s a brief write-up of both spawn and exec in the “Ruby Plumber’s
Guide” presentations at the link in my sig.

Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net

raise ArgumentError unless @reality.responds_to? :reason