Subprocess or Thread


#1

Hi,

i’ve a method in ruby with is running for long time (hast to watch for
events)

I’ve tried to do it in an Thread, but it doesn’t work.

How can I do a block of code in an subprocess?

Thnx for help,

Michael


#2

Perhaps use BackgrounDRb. http://backgroundrb.rubyforge.org/ Note that
it’s not just for Rails.


#3

2007/7/5, Michael D. removed_email_address@domain.invalid:

i’ve a method in ruby with is running for long time (hast to watch for
events)

Can you show some code or give more detailed explanation what “watch
for events” really means?

I’ve tried to do it in an Thread, but it doesn’t work.

How can I do a block of code in an subprocess?

It’s as simple as this:

puts $$
fork do
puts $$
end

$ ruby -e ‘puts $$;fork do puts $$ end’
2512
2632

Whether you actually need another process depends on what you do.

Kind regards

robert