Forum: Ruby Subprocess or Thread

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Michael D. (Guest)
on 2007-07-05 15:14
(Received via mailing list)
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
Stephan D. (Guest)
on 2007-08-09 14:59
Perhaps use BackgrounDRb. http://backgroundrb.rubyforge.org/ Note that
it's not just for Rails.
Robert K. (Guest)
on 2007-08-09 15:53
(Received via mailing list)
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
This topic is locked and can not be replied to.