def process_iter(proc, cmd="<STR_LIT>"):
try:<EOL><INDENT>for l in proc.stdout:<EOL><INDENT>yield l<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if proc.poll() is None:<EOL><INDENT>return<EOL><DEDENT>else:<EOL><INDENT>proc.wait()<EOL>if proc.returncode not in (<NUM_LIT:0>, None, signal.SIGPIPE, signal.SIGPIPE + <NUM_LIT>):<EOL><INDENT>sys.stderr.write("<STR_LIT>" % cmd)<EOL>sys.stderr.write("<STR_LIT>" % proc.returncode)<EOL>raise ProcessException(cmd)<EOL><DEDENT><DEDENT><DEDENT>
helper function to iterate over a process stdout
and report error messages when done