def METHOD_NAME(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