_logger.debug("Spawned sub pid: {} args: {} stdout: {} stderr{}".format(p.pid, p.args, out_path, err_path))
return tmp_id
- def run(self, command_line, cwd=None, check_return=True):
+ def run(self, command_line, cwd=None, check_return=True, ld_preload=""):
"""
Run the command and return a tuple of a (CompletedProcess, stdout_path,
stderr_path). The subprocess is already executed and returned. The
args = shlex.split(command_line)
env = self.get_env()
+ if ld_preload:
+ env['LD_PRELOAD'] = ld_preload
+
+
tmp_id = self._run_command_count
self._run_command_count += 1
env_path = os.path.join(self.__runtime_log, str(tmp_id) + ".env")
with open(env_path, 'w') as env_out:
- pprint.pprint(env, stream=env_out)
+ for key, value in env.items():
+ env_out.write('{}={}\n'.format(key, value))
cp = subprocess.run(args, stdout=stdout, stderr=stderr, env=env, cwd=cwd)
_logger.debug("Command #{} args: {} stdout: {} stderr{}".format(tmp_id, cp.args, out_path, err_path))