I've read the other references to daemonizing a process in ruby, but ... 
well there's not enough to the examples to get me going properly.

I'm using Ruby 1.8 on a Linux box.

I am trying to write a function which will daemonize the current script 
into one child process, which will then run isolated from the tty. 
Using information found here (at the forum) and in other places, I wrote 
this function:

def daemonize()
  #
  # process documented in 
http://blog.humlab.umu.se/samuel/archives/000107.html
  #
  begin
    exit if fork
    Process.setsid
    exit if fork
    File.umask 0774
    STDIN.reopen "/dev/null"     # no stdin
    STDOUT.reopen $log
    STDERR.reopen STDOUT         # stderr & stdout to syslog
  rescue
    raise "could not daemonize the process."
  end
end # gvp_daemonize()

Then I read in the 2nd Ed Pragmatic Ruby that there should be a 
Process.detach, if I don't care about the parent getting feedback (which 
I don't)., so I changed my first "exit if fork" to "if fork { 
Process.detach\nexit }"

The problem is that the process just exits.  Nothing else gets done.  I 
know I'm doing something wrong, but I'm too much of a ruby-nuby (oh, 
gee, and fork nuby too) to grok it from the examples I've seen, and the 
book, and the web ... HELP please.

FYI: I also need to figure out how to reset the userid and groupid, but 
I have a book. :)

Thanks for any assistance rendered.

Rogue Amateur

-- 
Posted via http://www.ruby-forum.com/.