code: def monitor():
      (ref, remote, expected_sha) = git_branch_info_to_track()
      expected_line = "{}\t{}".format(expected_sha, ref)
  
      if should_keep_alive(git("show", "-s", "--format=%B", "HEAD^-")):
          logger.info(
              "Not monitoring %s on %s due to keep-alive on: %s",
              ref,
              remote,
              expected_line,
          )
          return
  
      logger.info(
          "Monitoring %s (%s) for changes in %s: %s",
          remote,
          get_remote_url(remote),
          ref,
          expected_line,
      )
  
      for to_wait in yield_poll_schedule():
          time.sleep(to_wait)
          status = 0
          line = None
          try:
              # Query the commit on the remote ref (without fetching the commit).
              line = git("ls-remote", "--exit-code", remote, ref)
          except subprocess.CalledProcessError as ex:
              status = ex.returncode
  
          if status == 2:
              logger.info(
                  "Terminating job as %s has been deleted on %s: %s",
                  ref,
                  remote,
                  expected_line,
              )
              break
          elif status != 0:
              logger.error(
                  "Error %d: unable to check %s on %s: %s",
                  status,
                  ref,
                  remote,
                  expected_line,
              )
          else:
              prev = expected_line
              expected_line = detect_spurious_commit(
                  line, expected_line, remote
              )
              if expected_line != line:
                  logger.info(
                      "Terminating job as %s has been updated on %s\n"
                      "    from:\t%s\n"
                      "    to:  \t%s",
                      ref,
                      remote,
                      expected_line,
                      line,
                  )
                  time.sleep(1)  # wait for CI to flush output
                  break
              if expected_line != prev:
                  logger.info(
                      "%s appeared to spuriously change on %s\n"
                      "    from:\t%s\n"
                      "    to:  \t%s",
                      ref,
                      remote,
                      prev,
                      expected_line,
                  )
  
      return terminate_my_process_group()
  
imports: import argparse
  import errno
  import logging
  import os
  import signal
  import subprocess
  import sys
  import time
label_desc: Use image node_id 13 for calling a global function with example usage: monitor() and returns: terminate_my_process_group