Index: subprocess.py =================================================================== --- subprocess.py (revision 77683) +++ subprocess.py (working copy) @@ -948,7 +948,11 @@ if self.stdin: if input is not None: - self.stdin.write(input) + try: + self.stdin.write(input) + except (IOError, OSError), e: + if e.errno != errno.EPIPE: + raise self.stdin.close() if self.stdout: @@ -1292,7 +1296,12 @@ for fd, mode in ready: if mode & select.POLLOUT: chunk = input[input_offset : input_offset + _PIPE_BUF] - input_offset += os.write(fd, chunk) + try: + input_offset += os.write(fd, chunk) + except (IOError, OSError), e: + if e.errno != errno.EPIPE: + raise + input_offset = len(input) if input_offset >= len(input): close_unregister_and_remove(fd) elif mode & select_POLLIN_POLLPRI: