> 
> It looks like 1.9's Process.daemon uses exit! and it doesn't look like
> it does a double-fork which is a best-practice sort of thing (in order
> to avoid acquiring a new controlling terminal).  I suppose I should
> open a ticket...
> 
> Gary Wright

Something like this perhaps?

  def RDaemon.daemon(&block)
    unless fork
      Process::setsid
      unless fork
        Dir::chdir('/')
  File::umask(0)
  STDIN.reopen("/dev/null")
  STDOUT.reopen("/dev/null", "a") unless $DEBUG
  STDERR.reopen("/dev/null", "a") unless $DEBUG
  loop do
          yield
        end
      end
    end
    exit!(0)
  end


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