On Jul 2, 1:12 pm, 7stud <[EMAIL PROTECTED]> wrote: > Hi, > > Can someone explain what a broken pipe is? The following produces a > broken pipe error: > > ---------- > import subprocess as sub > > p = sub.Popen(["ls", "-al", "../"], stdin=sub.PIPE, stdout=sub.PIPE) > > print p.stdout.read() > #outputs the files correctly > > p.stdin.write("ls\n") > #IOError: [Errno 32] Broken pipe > -----------
You are seeing this error because sub.Popen closes both stdin and stdout once the subprocess terminates (which it must have done for p.stdout.read() to return a result). Consequently you are trying to write to a pipeline whose reader has already closed it, hence the error message. regards Steve -- http://mail.python.org/mailman/listinfo/python-list