mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-05 18:37:17 +00:00
lit: Make sure to close any files we open as part of redirection.
PR6753. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100032 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e1b55d672
commit
c3681d334a
@ -63,6 +63,7 @@ def executeShCmd(cmd, cfg, cwd, results):
|
||||
procs = []
|
||||
input = subprocess.PIPE
|
||||
stderrTempFiles = []
|
||||
opened_files = []
|
||||
# To avoid deadlock, we use a single stderr stream for piped
|
||||
# output. This is null until we have seen some output using
|
||||
# stderr.
|
||||
@ -115,6 +116,7 @@ def executeShCmd(cmd, cfg, cwd, results):
|
||||
# Workaround a Win32 and/or subprocess bug when appending.
|
||||
if r[1] == 'a':
|
||||
r[2].seek(0, 2)
|
||||
opened_files.append(r[2])
|
||||
result = r[2]
|
||||
final_redirects.append(result)
|
||||
|
||||
@ -176,7 +178,7 @@ def executeShCmd(cmd, cfg, cwd, results):
|
||||
else:
|
||||
err = ''
|
||||
procData[i] = (out,err)
|
||||
|
||||
|
||||
# Read stderr out of the temp files.
|
||||
for i,f in stderrTempFiles:
|
||||
f.seek(0, 0)
|
||||
@ -199,6 +201,10 @@ def executeShCmd(cmd, cfg, cwd, results):
|
||||
else:
|
||||
exitCode = res
|
||||
|
||||
# Explicitly close any redirected files.
|
||||
for f in opened_files:
|
||||
f.close()
|
||||
|
||||
if cmd.negate:
|
||||
exitCode = not exitCode
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user