code: def terminate_executor_shell_and_children(pid):
      p = psutil.Process(pid)
  
      # Terminate children gracefully.
      for child in p.children():
          try:
              child.terminate()
          except psutil.NoSuchProcess:
              pass
  
      # Wait for graceful termination.
      time.sleep(GRACEFUL_TERMINATION_TIME_S)
  
      # Send STOP to executor shell to stop progress.
      p.send_signal(signal.SIGSTOP)
  
      # Kill children recursively.
      for child in p.children(recursive=True):
          try:
              child.kill()
          except psutil.NoSuchProcess:
              pass
  
      # Kill shell itself.
      p.kill()
  
file_path: bluefog/bluefog/run/horovodrun/common/util/safe_shell_exec.py
imports: import os
  import psutil
  import signal
  import subprocess
  import sys
  import threading
  import time
label_desc: Use image node_id 1 for calling a global function with example usage: terminate_executor_shell_and_children(pid) without return types