views:

12

answers:

1

Hi,

I use Ruby 1.9 and the following method inside my program:

Process.daemon

Then, when I open a new terminal, I would like to call my daemonized program (named my_program) and send to it a message. Such as this:

$ my_program --are_you_still_alive

Thank you for any idea.

A: 

Hello, you could use signals to determine if the program is still alive

Signal.trap("USR1") do
  puts "I'm alive"
end

then you call

$ kill -USR1 $(pidof my_program)
lukstei
Thanks for your answer, Lukstei. But I just would like to send it a message. My trouble is that, when the process become a daemon I don't know how to contact it.
moshimoshi
oh then try using Distributed Ruby (http://segment7.net/projects/ruby/drb/index.html)
lukstei