def _setup_env(self):
prefix = "/dev/shm/tracer_"
curdir = os.getcwd()
tmpdir = tempfile.mkdtemp(prefix=prefix)
# dont prefilter the core
if len(self.binaries) > 1:
with open("/proc/self/coredump_filter", "wb") as f:
f.write("00000077")
# allow cores to be dumped
saved_limit = resource.getrlimit(resource.RLIMIT_CORE)
resource.setrlimit(resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY))
binaries_old = [ ]
for binary in self.binaries:
binaries_old.append(os.path.abspath(binary))
self.binaries = list(binaries_old)
os.chdir(tmpdir)
try:
yield (tmpdir, self.binaries[0])
finally:
assert tmpdir.startswith(prefix)
shutil.rmtree(tmpdir)
os.chdir(curdir)
resource.setrlimit(resource.RLIMIT_CORE, saved_limit)
self.binaries = binaries_old
评论列表
文章目录