code: def _check_pid_running(pid):
      # Check whether process still running.
      # FIXME: the correct impl should be using ``proc.poll()``
      # Using pid here is unsafe.
      # We should make Popen object directly accessible.
      if sys.platform == "win32":
          # NOTE: Tests show that the behavior of psutil is unreliable, and varies from runs to runs.
          # Also, Windows didn't explicitly handle child / non-child process.
          # This might be a potential problem.
          try:
              psutil.Process(pid).wait(timeout=0)
              return False
          except psutil.TimeoutExpired:
              return True
          except psutil.NoSuchProcess:
              return False
      else:
          try:
              indicator, _ = os.waitpid(pid, os.WNOHANG)
              return indicator == 0
          except ChildProcessError:
              # One of the reasons we reach here is: pid may be not a child process.
              # In that case, we can use the famous kill 0 to poll the process.
              try:
                  os.kill(pid, 0)
                  return True
              except OSError:
                  return False
  
file_path: nni/nni/tools/nnictl/command_utils.py
imports: from subprocess import call, check_output
  import sys
  import os
  import time
  import signal
  import psutil
  from .common_utils import print_error, print_warning
label_desc: Use image node_id 6 for calling a global function with example usage: _check_pid_running(pid) and returns: False, unknown, True, False, True, False