import errno


def _split_err(err):
    """Split exc_info() (if any) into one of two "signal based"
    errors, or generic non-signal error.  Returns a trio
    (pipe_err, intr_err, regular_err) with at most one being
    non-None.
    """
    if err is None:
        return None, None, None
    if isinstance(err[1], IOError) and err[1].errno == errno.EPIPE:
        return err, None, None
    if isinstance(err[1], KeyboardInterrupt):
        return None, err, None
    return None, None, err