From ff50e8e5ae1af23788a33c5296dd2009f3b8baf7 Mon Sep 17 00:00:00 2001 From: Richard Lowe Date: Tue, 24 Jul 2012 03:56:16 +0000 Subject: 2599 git-pbchk suffers classic pipe deadlock Reviewed by: Joshua M. Clulow Approved by: Garrett D'Amore --- usr/src/tools/scripts/git-pbchk.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'usr/src/tools/scripts/git-pbchk.py') diff --git a/usr/src/tools/scripts/git-pbchk.py b/usr/src/tools/scripts/git-pbchk.py index 59af2f3832..74be6a4818 100644 --- a/usr/src/tools/scripts/git-pbchk.py +++ b/usr/src/tools/scripts/git-pbchk.py @@ -24,6 +24,7 @@ import os import re import subprocess import sys +import tempfile from cStringIO import StringIO @@ -62,15 +63,24 @@ def git(command): command = ["git"] + command - p = subprocess.Popen(command, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + try: + tmpfile = tempfile.TemporaryFile(prefix="git-nits") + except EnvironmentError, e: + raise GitError("Could not create temporary file: %s\n" % e) + + try: + p = subprocess.Popen(command, + stdout=tmpfile, + stderr=subprocess.STDOUT) + except OSError, e: + raise GitError("could not execute %s: %s\n" (command, e)) err = p.wait() if err != 0: raise GitError(p.stdout.read()) - return p.stdout + tmpfile.seek(0) + return tmpfile def git_root(): -- cgit v1.2.3