<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def process_iter(proc, cmd=""):
 """ helper function to iterate over a process stdout and report error messages when done """

    try:
        for l in proc.stdout:
            yield l
    finally:
        if proc.poll() is None:
            # there was an exception
            return
        else:
            proc.wait()
            if proc.returncode not in (0, None, signal.SIGPIPE, signal.SIGPIPE + 128):
                sys.stderr.write("cmd was:%s\n" % cmd)
                sys.stderr.write("return code was:%s\n" % proc.returncode)
                raise ProcessException(cmd)