docs: def daemonize(stdin=os.devnull, stdout=os.devnull, stderr=os.devnull):
      '''
      This forks the current process into a daemon.
      The stdin, stdout, and stderr arguments are file names that
      will be opened and be used to replace the standard file descriptors
      in sys.stdin, sys.stdout, and sys.stderr.
      These arguments are optional and default to /dev/null.
  
      The fork will switch to the given directory.
  
      Used by external projects (ft).
      '''
      # Redirect standard file descriptors.
      si = open(stdin, 'r')
      os.dup2(si.fileno(), sys.stdin.fileno())
      try:
          log.FluLogKeeper.redirect_to(stdout, stderr)
      except IOError, e:
          if e.errno == errno.EACCES:
              sys.stderr.write('Permission denied writing to log file %s.' %\
                               e.filename)
  
      global is_already_daemon
      if is_already_daemon:
          return
  
      # first fork
      _fork()
      # do second fork
      _fork()
      # Now I am a daemon!
      # don't add stuff here that can fail, because from now on the program
      # will keep running regardless of tracebacks
      is_already_daemon = True