Module Daemon
In: util/daemon.rb

Methods to become a daemon process, disconnected fom the parent process.

Methods
daemon    rc_daemon    tommy_mode   
Public Instance methods
tommy_mode()

Become deaf, dumb, and blind. Play a mean pinball.

# File util/daemon.rb, line 46
  def tommy_mode()
    devnullin = File::open("/dev/null", "r")
    $stdin.reopen(devnullin)
    devnullin.close
    devnullout = File::open("/dev/null", "w")
    $stdout.reopen(devnullout)
    $stderr.reopen(devnullout)
    devnullout.close
  end
daemon(*args) {|*args| ...}

From Stevens APUE pp 417-418: become a daemon.

*args
Args passed to child process.
# File util/daemon.rb, line 59
  def daemon(*args)
    fork {
      Process.setsid
      Dir.chdir("/")
      exit(yield(*args))
    }
    exit!
  end
rc_daemon(*args)

Remote control: like above, but return child pid to caller.

*args
Args passed to child process.
# File util/daemon.rb, line 71
  def rc_daemon(*args)
    pid = fork
    if pid == 0
      setsid()
      exec(*args)
      _exit!
    else
      return pid
    end
  end