Pkg.getstatusoutput: Close process stdout as soon as we're done with it

This commit is contained in:
Ville Skyttä 2015-07-08 16:41:13 +03:00
parent f427637004
commit e8dc19461b
1 changed files with 3 additions and 2 deletions

5
Pkg.py
View File

@ -113,12 +113,13 @@ def getstatusoutput(cmd, stdoutonly=False, shell=False, raw=False):
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, close_fds=True)
proc.stdin.close()
text = proc.stdout.read()
with proc.stdout:
text = proc.stdout.read()
sts = proc.wait()
if not raw:
text = b2s(text)
if text.endswith('\n'):
text = text[:-1]
sts = proc.wait()
if sts is None:
sts = 0
return sts, text