code: def run_custom_bird_reconfigure(operation):
      
      log = logging.getLogger(PROGRAM_NAME)
      if isinstance(operation, AddOperation):
          status = 'up'
      else:
          status = 'down'
      cmd = shlex.split(operation.bird_reconfigure_cmd + " " + status)
      log.info("reconfiguring BIRD by running custom command %s", ' '.join(cmd))
      try:
          proc = subprocess.Popen(cmd,
                                  start_new_session=True,
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
          _, errs = proc.communicate(
              timeout=operation.bird_reconfigure_timeout
          )
      except OSError as exc:
          log.error("reconfiguring BIRD failed with: %s", exc)
      except subprocess.TimeoutExpired as exc:
          log.error("reconfiguring bird timed out")
          if proc.poll() is None:  # if process is still alive
              try:
                  os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
              except PermissionError as exc:
                  log.error("failed to terminate custom bird command: %s", exc)
      else:
          if proc.returncode != 0:
              log.error("reconfiguring BIRD failed with return code: %s and "
                        "stderr: %s", proc.returncode, errs)
          else:
              log.info("custom command successfully reconfigured Bird")
docs: Reconfigure BIRD daemon by running a custom command.
  
      It adds one argument to the command, either "up" or "down".
      If command times out then we kill it. In order to avoid leaving any orphan
      processes, that may have been started by the command, we start a new
      session when we invoke the command and then we kill process group of that
      session.
  
      Arguments:
          operation (obj): Either a AddOperation or DeleteOperation object.