changeset 13757:2e70a48f5fe2

2599 git-pbchk suffers classic pipe deadlock Reviewed by: Joshua M. Clulow <josh@sysmgr.org> Approved by: Garrett D'Amore <garrett@damore.org>
author Richard Lowe <richlowe@richlowe.net>
date Tue, 24 Jul 2012 03:56:16 +0000
parents 281242a86f07
children 23432da34147
files usr/src/tools/scripts/git-pbchk.py
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/tools/scripts/git-pbchk.py	Sun Jul 22 00:00:47 2012 +0000
+++ b/usr/src/tools/scripts/git-pbchk.py	Tue Jul 24 03:56:16 2012 +0000
@@ -24,6 +24,7 @@
 import re
 import subprocess
 import sys
+import tempfile
 
 from cStringIO import StringIO
 
@@ -62,15 +63,24 @@
 
     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():