code: def catch_zombie(proc):
      """There are some poor C APIs which incorrectly raise ESRCH when
      the process is still alive or it's a zombie, or even RuntimeError
      (those who don't set errno). This is here in order to solve:
      https://github.com/giampaolo/psutil/issues/1044
      """
      try:
          yield
      except (OSError, RuntimeError) as err:
          if isinstance(err, RuntimeError) or err.errno == errno.ESRCH:
              try:
                  # status() is not supposed to lie and correctly detect
                  # zombies so if it raises ESRCH it's true.
                  status = proc.status()
              except NoSuchProcess:
                  raise err
              else:
                  if status == _common.STATUS_ZOMBIE:
                      raise ZombieProcess(
                          proc.pid, proc._name, proc._ppid
                      )
                  else:
                      raise AccessDenied(proc.pid, proc._name)
          else:
              raise
  
imports: import contextlib
  import errno
  import functools
  import os
  from collections import namedtuple
  from .None import _common
  from .None import _psposix
  from .None import _psutil_osx
  from .None import _psutil_posix
  from ._common import AccessDenied
  from ._common import conn_tmap
  from ._common import conn_to_ntuple
  from ._common import isfile_strict
  from ._common import memoize_when_activated
  from ._common import NoSuchProcess
  from ._common import parse_environ_block
  from ._common import usage_percent
  from ._common import ZombieProcess
  from ._compat import PermissionError
  from ._compat import ProcessLookupError
label_desc: Use image node_id 18 for calling a global function with example usage: catch_zombie(proc) without return types