mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 00:17:01 +00:00
[lit] Move executeCommand() into lit.util.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188356 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2,6 +2,8 @@ import errno
|
||||
import itertools
|
||||
import math
|
||||
import os
|
||||
import platform
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@@ -138,3 +140,20 @@ def printHistogram(items, title = 'Items'):
|
||||
pDigits, pfDigits, i*barH, pDigits, pfDigits, (i+1)*barH,
|
||||
'*'*w, ' '*(barW-w), cDigits, len(row), cDigits, len(items)))
|
||||
|
||||
# Close extra file handles on UNIX (on Windows this cannot be done while
|
||||
# also redirecting input).
|
||||
kUseCloseFDs = not (platform.system() == 'Windows')
|
||||
def executeCommand(command, cwd=None, env=None):
|
||||
p = subprocess.Popen(command, cwd=cwd,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
env=env, close_fds=kUseCloseFDs)
|
||||
out,err = p.communicate()
|
||||
exitCode = p.wait()
|
||||
|
||||
# Detect Ctrl-C in subprocess.
|
||||
if exitCode == -signal.SIGINT:
|
||||
raise KeyboardInterrupt
|
||||
|
||||
return out, err, exitCode
|
||||
|
||||
Reference in New Issue
Block a user