def _reapchildren(children):
    """
    Check all <children> Popen objects in the dictionary for returncodes.

    Yield the result if they have completed.

    :param children:
    :return:
    """
    for pid in list(children.keys()):
        ret = children[pid].poll()
        if ret is None:
            continue
        msg = 'child exited with %s' % ret
        yield children[pid].number, children[pid], msg, list(children.keys())
        del children[pid]
