import errno


def goodwait(proc):
    """Safely wait for a process"""
    while True:
        try:
            ret_val = proc.wait()
            return ret_val
        except OSError as e:  # pylint: disable=C0103
            # pylint: disable=E0602
            if e.errno != errno.EINTR:
                raise