diff --git a/git/cmd.py b/git/cmd.py index 2d4aa7279..b8b27d42f 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -73,6 +73,9 @@ def __init__(self, proc, args ): self.args = args def __del__(self): + self.proc.stdout.close() + self.proc.stderr.close() + # did the process finish already so we have a return code ? if self.proc.poll() is not None: return @@ -84,6 +87,8 @@ def __del__(self): # try to kill it try: os.kill(self.proc.pid, 2) # interrupt signal + except OSError: + pass # ignore error when process already died except AttributeError: # try windows # for some reason, providing None for stdout/stderr still prints something. This is why @@ -100,6 +105,8 @@ def wait(self): :raise GitCommandError: if the return status is not 0""" status = self.proc.wait() + self.proc.stdout.close() + self.proc.stderr.close() if status != 0: raise GitCommandError(self.args, status, self.proc.stderr.read()) # END status handling