[ASan] Close stderr before launching atos in asan_symbolize.py

llvm-svn: 185631
This commit is contained in:
Alexander Potapenko 2013-07-04 14:21:49 +00:00
parent 5dac06ff4b
commit 4f73dea69d
1 changed files with 6 additions and 3 deletions

View File

@ -142,10 +142,13 @@ class UnbufferedLineConverter(object):
Wrap a child process that responds to each line of input with one line of Wrap a child process that responds to each line of input with one line of
output. Uses pty to trick the child into providing unbuffered output. output. Uses pty to trick the child into providing unbuffered output.
""" """
def __init__(self, args): def __init__(self, args, close_stderr=False):
pid, fd = pty.fork() pid, fd = pty.fork()
if pid == 0: if pid == 0:
# We're the child. Transfer control to command. # We're the child. Transfer control to command.
if close_stderr:
dev_null = os.open('/dev/null', 0)
os.dup2(dev_null, 2)
os.execvp(args[0], args) os.execvp(args[0], args)
else: else:
# Disable echoing. # Disable echoing.
@ -179,7 +182,7 @@ class DarwinSymbolizer(Symbolizer):
if DEBUG: if DEBUG:
print 'atos -o %s -arch %s' % (self.binary, self.arch) print 'atos -o %s -arch %s' % (self.binary, self.arch)
cmdline = ['atos', '-o', self.binary, '-arch', self.arch] cmdline = ['atos', '-o', self.binary, '-arch', self.arch]
self.atos = UnbufferedLineConverter(cmdline) self.atos = UnbufferedLineConverter(cmdline, close_stderr=True)
def symbolize(self, addr, binary, offset): def symbolize(self, addr, binary, offset):
"""Overrides Symbolizer.symbolize.""" """Overrides Symbolizer.symbolize."""