def METHOD_NAME(self, pid, name):
    """Wait for the given process to terminate.
    @return tuple of exit code and resource usage
    """
    try:
        logging.debug("Waiting for process %s with pid %s", name, pid)
        unused_pid, exitcode, ru_child = os.wait4(pid, 0)
        return exitcode, ru_child
    except OSError as e:
        if self.PROCESS_KILLED and e.errno == errno.EINTR:
            # Interrupted system call seems always to happen
            # if we killed the process ourselves after Ctrl+C was pressed
            # We can try again to get exitcode and resource usage.
            logging.debug(
                "OSError %s while waiting for termination of %s (%s): %s.",
                e.errno,
                name,
                pid,
                e.strerror,
            )
            try:
                unused_pid, exitcode, ru_child = os.wait4(pid, 0)
                return exitcode, ru_child
            except OSError:
                pass  # original error will be handled and this ignored
        logging.critical(
            "OSError %s while waiting for termination of %s (%s): %s.",
            e.errno,
            name,
            pid,
            e.strerror,
        )
        return 0, None