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.
9f937facbd3ab30eb6d300a712188dde?d=identicon&s=25 Michael Dichtl (Guest)
on 2007-07-05 13: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
1924957eee03ddf35a65a3e8337f7f20?d=identicon&s=25 Stephan Dale (stephan)
on 2007-08-09 12:59
Perhaps use BackgrounDRb. http://backgroundrb.rubyforge.org/ Note that
it's not just for Rails.
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2007-08-09 13:53
(Received via mailing list)
2007/7/5, Michael Dichtl <mdi@meta-1.com>:
> 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.