fix broken pipe crash in run_pip()

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-06-01 14:36:07 -04:00
parent 5cd69146a6
commit 02da5d5d3c
1 changed files with 7 additions and 2 deletions

View File

@ -734,8 +734,13 @@ class Application(object):
def run_pipe(self, args, b, name='*Output*', switch=True, modename=None):
pipe = Popen(args=args, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
data = b.make_string().encode('utf-8')
try:
pipe.stdin.write(data)
pipe.stdin.close()
except IOError:
# sometimes the program will stop reading from stdin before we're
# done. this is fine and we should ignore the IOError.
pass
output = pipe.stdout.read()
status = pipe.wait()
if callable(switch):