chiark / gitweb /
make sure file-streams of subprocesses get closed
authorMichael Pöhn <michael.poehn@fsfe.org>
Thu, 7 Sep 2017 00:36:58 +0000 (02:36 +0200)
committerMichael Pöhn <michael.poehn@fsfe.org>
Thu, 7 Sep 2017 00:36:58 +0000 (02:36 +0200)
fdroidserver/common.py

index 95b1b06c0a97e34a67a222dff9dac9cdd8e08a4d..43471bfcbc39a7b5e23d9f16b990ab4e93779313 100644 (file)
@@ -1789,6 +1789,12 @@ def FDroidPopenBytes(commands, cwd=None, envs=None, output=True, stderr_to_stdou
     result.returncode = p.wait()
     result.output = buf.getvalue()
     buf.close()
+    # make sure all filestreams of the subprocess are closed
+    for streamvar in ['stdin', 'stdout', 'stderr']:
+        if hasattr(p, streamvar):
+            stream = getattr(p, streamvar)
+            if stream:
+                stream.close()
     return result