def daemonize
      Kernel.srand
      exit if Kernel.fork
      unless Process.setsid
        @logger.fatal("cannot detach from controlling terminal")
        @logger.fatal("SENSU NOT RUNNING!")
        exit 2
      end
      Signal.trap("SIGHUP", "IGNORE")
      exit if Kernel.fork
      Dir.chdir("/")
      ObjectSpace.each_object(IO) do |io|
        unless [STDIN, STDOUT, STDERR].include?(io)
          begin
            io.close unless io.closed?
          rescue; end
        end
      end
    end
def daemonize
      Kernel.srand
      exit if Kernel.fork
      unless Process.setsid
        @logger.fatal("cannot detach from controlling terminal")
        @logger.fatal("SENSU NOT RUNNING!")
        exit 2
      end
      Signal.trap("SIGHUP", "IGNORE")
      exit if Kernel.fork
      Dir.chdir("/")
      ObjectSpace.each_object(IO) do |io|
        unless [STDIN, STDOUT, STDERR].include?(io)
          begin
            io.close unless io.closed?
          rescue; end
        end
      end
    end
Daemonize the current process. Seed the random number generator,
 fork (& exit), detach from controlling terminal, ignore SIGHUP,
 fork (& exit), use root '/' as the current working directory,
 and close STDIN/OUT/ERR since the process is no longer attached
 to a terminal.