code: def guard(pidfile, guardfile=None):
      
      # Check guard
      if guardfile and not os.path.exists(guardfile):
          raise EnvironmentError("Guard file '%s' not found, won't start!" % guardfile)
  
      if os.path.exists(pidfile):
          running, pid = check_process(pidfile)
          if running:
              raise EnvironmentError("Daemon process #%d still running, won't start!" % pid)
          else:
              logging.getLogger("daemonize").info("Process #%d disappeared, continuing..." % pid)
  
      # Keep race condition window small, by immediately writing launcher process ID
      _write_pidfile(pidfile)
docs: Raise an EnvironmentError when the "guardfile" doesn't exist, or
          the process with the ID found in "pidfile" is still active.