code: def _handle_proc_keyboard_interrupt(proc):
      log_waiting_after = time.time() + LOG_WAITING_DELAY_SECONDS
      kill_after = time.time() + PROC_TERM_TIMEOUT_SECONDS
      while time.time() < kill_after:
          if log_waiting_after and time.time() > log_waiting_after:
              if os.getenv("NO_OP_INTERRUPTED_MSG") != "1":
                  log.info(
                      "Operation interrupted - waiting for process to exit"
                  )
              log_waiting_after = None
          if proc.poll() is not None:
              return proc.returncode
          time.sleep(1)
      log.warning(
          "Operation process did not exit - stopping forcefully"
      )
      util.kill_process_tree(proc.pid, force=True)
      if proc.poll():
          return proc.returncode
      return exit_code.KEYBOARD_INTERRUPT
  
imports: import logging
  import os
  import subprocess
  import time
  from guild import config
  from guild import exit_code
  from guild import log
  from guild import op_dep
  from guild import op_util
  from guild import run
  from guild import util
label_desc: Use image node_id 25 for calling a global function with example usage: _handle_proc_keyboard_interrupt(proc) and returns: exit_code, proc, proc