From 4a8a8c8592ad11d767802c363a4c360bddd2f1c1 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Sat, 27 Sep 2014 01:22:27 +0000 Subject: [PATCH] Close process FDs after __init__() sanity check. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * FIXES and issue discovered by ttanner (https://github.com/ttanner) in `gnupg._meta.GPGBase._check_sane_and_get_gpg_version()` where the GnuPG process wasn't closed and its file descriptors were left hanging. * FIXES part of Issue #63. https://github.com/isislovecruft/python-gnupg/issues/63 There were so many hanging FD issues when I started patching upstream python-gnupg ― I doubt I found all of them. I probably even introduced some along the way. And, as ttanner pointed out, this patch doesn't fix the issue fully, so there are likely more. --- gnupg/_meta.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gnupg/_meta.py b/gnupg/_meta.py index 94261f0..53d7620 100644 --- a/gnupg/_meta.py +++ b/gnupg/_meta.py @@ -448,6 +448,8 @@ class GPGBase(object): self._read_data(proc.stdout, result) if proc.returncode: raise RuntimeError("Error invoking gpg: %s" % result.data) + else: + proc.terminate() version_line = str(result.data).partition(':version:')[2] self.binary_version = version_line.split('\n')[0]