def daemonize(safe = true)
      $stdin.reopen '/dev/null'

      # Fork and have the parent exit.
      # This makes the shell or boot script think the command is done.
      # Also, the child process is guaranteed not to be a process group
      # leader (a prerequisite for setsid next)
      exit if fork

      # Call setsid to create a new session. This does three things:
      # - The process becomes a session leader of a new session
      # - The process becomes the process group leader of a new process group
      # - The process has no controlling terminal
      Process.setsid

      # Fork again and have the parent exit.
      # This guarantes that the daemon is not a session leader nor can
      # it acquire a controlling terminal (under SVR4)
      exit if fork

      unless safe
        ::Dir.chdir('/')
        ::File.umask(0000)
      end

      cfg_defaults = Clacks::Configurator::DEFAULTS
      cfg_defaults[:stdout_path] ||= "/dev/null"
      cfg_defaults[:stderr_path] ||= "/dev/null"
    end
def daemonize(safe = true)
      $stdin.reopen '/dev/null'

      # Fork and have the parent exit.
      # This makes the shell or boot script think the command is done.
      # Also, the child process is guaranteed not to be a process group
      # leader (a prerequisite for setsid next)
      exit if fork

      # Call setsid to create a new session. This does three things:
      # - The process becomes a session leader of a new session
      # - The process becomes the process group leader of a new process group
      # - The process has no controlling terminal
      Process.setsid

      # Fork again and have the parent exit.
      # This guarantes that the daemon is not a session leader nor can
      # it acquire a controlling terminal (under SVR4)
      exit if fork

      unless safe
        ::Dir.chdir('/')
        ::File.umask(0000)
      end

      cfg_defaults = Clacks::Configurator::DEFAULTS
      cfg_defaults[:stdout_path] ||= "/dev/null"
      cfg_defaults[:stderr_path] ||= "/dev/null"
    end
See Stevens's "Advanced Programming in the UNIX Environment" chapter 13