<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def custom_check(cmd, ignore_retcode=False):
 """Run command, collect output, raise error if needed. """

    p = custom_popen(cmd)
    out, _ = p.communicate()
    if p.returncode and not ignore_retcode:
        raise RarExecError("Check-run failed")
    return out