X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=lttng_ivc%2Futils%2Fruntime.py;h=0103dbf1b9e64848ab5dfbe2115d92a0eff6d320;hb=0a7e963afd224897461ffcc1fe089c48cb97aa3f;hp=ac19e107b8db88ea70fc9b55ed483ec68a06ab25;hpb=6aa98db5836fd75fff696f8d894455693ef6001a;p=deliverable%2Flttng-ivc.git diff --git a/lttng_ivc/utils/runtime.py b/lttng_ivc/utils/runtime.py index ac19e10..0103dbf 100644 --- a/lttng_ivc/utils/runtime.py +++ b/lttng_ivc/utils/runtime.py @@ -120,7 +120,7 @@ class Runtime(object): _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 @@ -129,6 +129,10 @@ class Runtime(object): 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 @@ -143,7 +147,8 @@ class Runtime(object): 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))