Close process FDs after __init__() sanity check.

* 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.
fix/63-hanging-fd
Isis Lovecruft 2014-09-27 01:22:27 +00:00
parent 432833bdcb
commit 4a8a8c8592
No known key found for this signature in database
GPG Key ID: 18C16EC5F9F1D673
1 changed files with 2 additions and 0 deletions

View File

@ -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]