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): def run_pipe(self, args, b, name='*Output*', switch=True, modename=None):
pipe = Popen(args=args, stdin=PIPE, stdout=PIPE, stderr=STDOUT) pipe = Popen(args=args, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
data = b.make_string().encode('utf-8') data = b.make_string().encode('utf-8')
pipe.stdin.write(data) try:
pipe.stdin.close() 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() output = pipe.stdout.read()
status = pipe.wait() status = pipe.wait()
if callable(switch): if callable(switch):